/**
poj 2749 Building roads #二分+2-sat
坐标系中有n个点和两个点s1,s2,每个点连到s1或s2上,连且只连一个,
求使得任意两点的曼哈顿距离中最大值 最小。
二分最大距离,
建图时注意两种矛盾类型,
1,喜欢与不喜欢,2,二分答案时距离超过答案
*/
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
using namespace std;
#define N 1024
#define INF 4000000
vector<int> vec[N];
int n,nn;
int A[N][2],B[N][2],S[2][2],d[N][2],ss;
int a,b;
int id[N],pre[N],s[N],low[N],stop,cnt,scnt;
void tarjan(int v)
{
int t, minc = low[v] = pre[v] = cnt ++;
s[stop++] = v;
vector<int>::iterator pv;
for(pv = vec[v].begin();pv != vec[v].end();++pv)
{
if(-