|  |  | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | #include <algorithm> | 
					
						
						|  | #include <functional> | 
					
						
						|  | #include <numeric> | 
					
						
						|  | #include <iostream> | 
					
						
						|  | #include <iomanip> | 
					
						
						|  | #include <cstdio> | 
					
						
						|  | #include <cmath> | 
					
						
						|  | #include <complex> | 
					
						
						|  | #include <cstdlib> | 
					
						
						|  | #include <ctime> | 
					
						
						|  | #include <cstring> | 
					
						
						|  | #include <cassert> | 
					
						
						|  | #include <string> | 
					
						
						|  | #include <vector> | 
					
						
						|  | #include <list> | 
					
						
						|  | #include <map> | 
					
						
						|  | #include <set> | 
					
						
						|  | #include <deque> | 
					
						
						|  | #include <queue> | 
					
						
						|  | #include <stack> | 
					
						
						|  | #include <bitset> | 
					
						
						|  | #include <sstream> | 
					
						
						|  | using namespace std; | 
					
						
						|  |  | 
					
						
						|  | #define LL long long | 
					
						
						|  | #define LD long double | 
					
						
						|  | #define PR pair<int,int> | 
					
						
						|  |  | 
					
						
						|  | #define Fox(i,n) for (i=0; i<n; i++) | 
					
						
						|  | #define Fox1(i,n) for (i=1; i<=n; i++) | 
					
						
						|  | #define FoxI(i,a,b) for (i=a; i<=b; i++) | 
					
						
						|  | #define FoxR(i,n) for (i=(n)-1; i>=0; i--) | 
					
						
						|  | #define FoxR1(i,n) for (i=n; i>0; i--) | 
					
						
						|  | #define FoxRI(i,a,b) for (i=b; i>=a; i--) | 
					
						
						|  | #define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++) | 
					
						
						|  | #define Min(a,b) a=min(a,b) | 
					
						
						|  | #define Max(a,b) a=max(a,b) | 
					
						
						|  | #define Sz(s) int((s).size()) | 
					
						
						|  | #define All(s) (s).begin(),(s).end() | 
					
						
						|  | #define Fill(s,v) memset(s,v,sizeof(s)) | 
					
						
						|  | #define pb push_back | 
					
						
						|  | #define mp make_pair | 
					
						
						|  | #define x first | 
					
						
						|  | #define y second | 
					
						
						|  |  | 
					
						
						|  | template<typename T> T Abs(T x) { return(x<0 ? -x : x); } | 
					
						
						|  | template<typename T> T Sqr(T x) { return(x*x); } | 
					
						
						|  |  | 
					
						
						|  | const int INF = (int)1e9; | 
					
						
						|  | const LD EPS = 1e-12; | 
					
						
						|  | const LD PI = acos(-1.0); | 
					
						
						|  |  | 
					
						
						|  | bool Read(int &x) | 
					
						
						|  | { | 
					
						
						|  | char c,r=0,n=0; | 
					
						
						|  | x=0; | 
					
						
						|  | for(;;) | 
					
						
						|  | { | 
					
						
						|  | c=getchar(); | 
					
						
						|  | if ((c<0) && (!r)) | 
					
						
						|  | return(0); | 
					
						
						|  | if ((c=='-') && (!r)) | 
					
						
						|  | n=1; | 
					
						
						|  | else | 
					
						
						|  | if ((c>='0') && (c<='9')) | 
					
						
						|  | x=x*10+c-'0',r=1; | 
					
						
						|  | else | 
					
						
						|  | if (r) | 
					
						
						|  | break; | 
					
						
						|  | } | 
					
						
						|  | if (n) | 
					
						
						|  | x=-x; | 
					
						
						|  | return(1); | 
					
						
						|  | } | 
					
						
						|  |  | 
					
						
						|  | #define LIM 900009 | 
					
						
						|  |  | 
					
						
						|  | int K,A,B; | 
					
						
						|  | map<int,int> M; | 
					
						
						|  | vector<int> con[LIM],con2[LIM]; | 
					
						
						|  | bool col0[LIM]; | 
					
						
						|  | int col[LIM],ind[LIM],P1[LIM],P2[LIM],dist[LIM]; | 
					
						
						|  |  | 
					
						
						|  | int Make(int i) | 
					
						
						|  | { | 
					
						
						|  | if (M.count(i)) | 
					
						
						|  | return(M[i]); | 
					
						
						|  | return(M[i]=K++); | 
					
						
						|  | } | 
					
						
						|  |  | 
					
						
						|  | bool DFS(int i,int c) | 
					
						
						|  | { | 
					
						
						|  |  | 
					
						
						|  | if ((col0[i]) && (c) || (col[i]>=0) && (c!=col[i])) | 
					
						
						|  | return(0); | 
					
						
						|  |  | 
					
						
						|  | if (col[i]>=0) | 
					
						
						|  | return(1); | 
					
						
						|  |  | 
					
						
						|  | col[i]=c; | 
					
						
						|  | int j; | 
					
						
						|  | Fox(j,Sz(con[i])) | 
					
						
						|  | if (!DFS(con[i][j],1-c)) | 
					
						
						|  | return(0); | 
					
						
						|  | return(1); | 
					
						
						|  | } | 
					
						
						|  |  | 
					
						
						|  | bool MatchBFS() | 
					
						
						|  | { | 
					
						
						|  | int i,a,b,a2; | 
					
						
						|  | queue<int> Q; | 
					
						
						|  | Fill(dist,60); | 
					
						
						|  | Fox(a,A) | 
					
						
						|  | if (P1[a]<0) | 
					
						
						|  | dist[a]=0,Q.push(a); | 
					
						
						|  | while (!Q.empty()) | 
					
						
						|  | { | 
					
						
						|  | a=Q.front(),Q.pop(); | 
					
						
						|  | if (dist[a]<dist[A]) | 
					
						
						|  | Fox(i,Sz(con2[a])) | 
					
						
						|  | { | 
					
						
						|  | b=con2[a][i]; | 
					
						
						|  | a2=P2[b]; | 
					
						
						|  | if (dist[a2]>=INF) | 
					
						
						|  | dist[a2]=dist[a]+1,Q.push(a2); | 
					
						
						|  | } | 
					
						
						|  | } | 
					
						
						|  | return(dist[A]<INF); | 
					
						
						|  | } | 
					
						
						|  |  | 
					
						
						|  | bool MatchDFS(int a) | 
					
						
						|  | { | 
					
						
						|  | if (a==A) | 
					
						
						|  | return(1); | 
					
						
						|  | int i,b,a2; | 
					
						
						|  | Fox(i,Sz(con2[a])) | 
					
						
						|  | { | 
					
						
						|  | b=con2[a][i]; | 
					
						
						|  | a2=P2[b]; | 
					
						
						|  | if ((dist[a2]==dist[a]+1) && (MatchDFS(a2))) | 
					
						
						|  | { | 
					
						
						|  | P1[a]=b; | 
					
						
						|  | P2[b]=a; | 
					
						
						|  | return(1); | 
					
						
						|  | } | 
					
						
						|  | } | 
					
						
						|  | dist[a]=INF; | 
					
						
						|  | return(0); | 
					
						
						|  | } | 
					
						
						|  |  | 
					
						
						|  | int MaxMatching() | 
					
						
						|  | { | 
					
						
						|  | int a,b,m=0; | 
					
						
						|  | Fill(P1,-1); | 
					
						
						|  | Fox(b,B) | 
					
						
						|  | P2[b]=A; | 
					
						
						|  | while (MatchBFS()) | 
					
						
						|  | { | 
					
						
						|  | Fox(a,A) | 
					
						
						|  | if ((P1[a]<0) && (MatchDFS(a))) | 
					
						
						|  | m++; | 
					
						
						|  | } | 
					
						
						|  | return(m); | 
					
						
						|  | } | 
					
						
						|  |  | 
					
						
						|  | int main() | 
					
						
						|  | { | 
					
						
						|  |  | 
					
						
						|  | int T,t; | 
					
						
						|  | int N=0; | 
					
						
						|  | int i,j,a,b,p,r,z,ans; | 
					
						
						|  |  | 
					
						
						|  | Read(T); | 
					
						
						|  | Fox1(t,T) | 
					
						
						|  | { | 
					
						
						|  |  | 
					
						
						|  | Fox(i,K) | 
					
						
						|  | con[i].clear(); | 
					
						
						|  | Fox(i,A) | 
					
						
						|  | con2[i].clear(); | 
					
						
						|  | K=0; | 
					
						
						|  | M.clear(); | 
					
						
						|  | Fill(col0,0); | 
					
						
						|  | Fill(col,-1); | 
					
						
						|  | Fill(ind,-1); | 
					
						
						|  | Fill(P1,-1); | 
					
						
						|  | Fill(P2,-1); | 
					
						
						|  |  | 
					
						
						|  | Read(N); | 
					
						
						|  | while (N--) | 
					
						
						|  | { | 
					
						
						|  | Read(p),Read(r); | 
					
						
						|  | i=Make(p),a=Make(p-r),b=Make(p+r); | 
					
						
						|  | col0[i]=1; | 
					
						
						|  | con[a].pb(b); | 
					
						
						|  | con[b].pb(a); | 
					
						
						|  | } | 
					
						
						|  |  | 
					
						
						|  | Fox(z,2) | 
					
						
						|  | Fox(i,K) | 
					
						
						|  | if (col[i]<0) | 
					
						
						|  | { | 
					
						
						|  | if ((!z) && (!col0[i])) | 
					
						
						|  | continue; | 
					
						
						|  | if (!DFS(i,0)) | 
					
						
						|  | { | 
					
						
						|  | ans=-1; | 
					
						
						|  | goto Done; | 
					
						
						|  | } | 
					
						
						|  | } | 
					
						
						|  |  | 
					
						
						|  | A=B=0; | 
					
						
						|  | Fox(i,K) | 
					
						
						|  | if (!col0[i]) | 
					
						
						|  | { | 
					
						
						|  | Fox(j,Sz(con[i])) | 
					
						
						|  | if (col0[con[i][j]]) | 
					
						
						|  | goto Skip; | 
					
						
						|  | if (!col[i]) | 
					
						
						|  | ind[i]=A++; | 
					
						
						|  | else | 
					
						
						|  | ind[i]=B++; | 
					
						
						|  | Skip:; | 
					
						
						|  | } | 
					
						
						|  | Fox(i,K) | 
					
						
						|  | if ((ind[i]>=0) && (!col[i])) | 
					
						
						|  | { | 
					
						
						|  | a=ind[i]; | 
					
						
						|  | Fox(j,Sz(con[i])) | 
					
						
						|  | { | 
					
						
						|  | b=ind[con[i][j]]; | 
					
						
						|  | if (b>=0) | 
					
						
						|  | con2[a].pb(b); | 
					
						
						|  | } | 
					
						
						|  | } | 
					
						
						|  | ans=A+B-MaxMatching()+1; | 
					
						
						|  |  | 
					
						
						|  | Done:; | 
					
						
						|  | printf("Case #%d: %d\n",t,ans); | 
					
						
						|  | } | 
					
						
						|  | return(0); | 
					
						
						|  | } |