ADDED   SRM/505-U/1Au.cpp
Index: SRM/505-U/1Au.cpp
==================================================================
--- SRM/505-U/1Au.cpp
+++ SRM/505-U/1Au.cpp
@@ -0,0 +1,170 @@
+#include <iostream>
+#include <sstream>
+#include <iomanip>
+#include <vector>
+#include <string>
+#include <map>
+#include <set>
+#include <algorithm>
+#include <numeric>
+#include <iterator>
+#include <functional>
+#include <complex>
+#include <queue>
+#include <stack>
+#include <cmath>
+#include <cassert>
+#include <cstring>
+using namespace std;
+typedef long long LL;
+typedef complex<double> CMP;
+
+class RectangleArea { public:
+	int minimumQueries(vector <string> known) 
+	{
+		const int H = known.size();
+		const int W = known[0].size();
+		for(int y=0; y<H; ++y)
+		for(int x=0; x<W; ++x)
+		for(int Y=0; Y<H; ++Y)
+		for(int X=0; X<W; ++X)
+		if( make_pair(y,x) < make_pair(Y,X) && y!=Y && x!=X )
+		if( known[y][x]=='Y' && known[Y][X]=='Y' )
+		{
+			if( known[y][X]=='Y' )
+				known[Y][x] = 'Y';
+			if( known[Y][x]=='Y' )
+				known[y][X] = 'Y';
+		}
+
+		int tt = 0;
+		for(int i=0; i<W; ++i)
+			if( known[0][i]=='N' )
+				++tt;
+		int yy = 0;
+		for(int i=0; i<H; ++i)
+			if( known[i][0]=='N' )
+				++yy;
+		if( tt == 0 )
+			return yy;
+		if( yy == 0 )
+			return tt;
+		return -1;	
+	}
+};
+
+// BEGIN CUT HERE
+#include <ctime>
+double start_time; string timer()
+ { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
+template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
+ { os << "{ ";
+   for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
+   os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
+void verify_case(const int& Expected, const int& Received) {
+ bool ok = (Expected == Received);
+ if(ok) cerr << "PASSED" << timer() << endl;  else { cerr << "FAILED" << timer() << endl;
+ cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } }
+#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
+#define END	 verify_case(_, RectangleArea().minimumQueries(known));}
+int main(){
+
+CASE(0)
+	string known_[] = {"NN",
+ "NN"};
+	  vector <string> known(known_, known_+sizeof(known_)/sizeof(*known_)); 
+	int _ = 3; 
+END
+CASE(1)
+	string known_[] = {"YNY",
+ "NYN",
+ "YNY"};
+	  vector <string> known(known_, known_+sizeof(known_)/sizeof(*known_)); 
+	int _ = 1; 
+END
+CASE(2)
+	string known_[] = {"YY",
+ "YY",
+ "YY",
+ "YY"};
+	  vector <string> known(known_, known_+sizeof(known_)/sizeof(*known_)); 
+	int _ = 0; 
+END
+CASE(3)
+	string known_[] = {"NNNNNNNNNN"};
+	  vector <string> known(known_, known_+sizeof(known_)/sizeof(*known_)); 
+	int _ = 10; 
+END
+CASE(4)
+	string known_[] = {"NNYYYNN",
+ "NNNNNYN",
+ "YYNNNNY",
+ "NNNYNNN",
+ "YYNNNNY"};
+	  vector <string> known(known_, known_+sizeof(known_)/sizeof(*known_)); 
+	int _ = 2; 
+END
+CASE(5)
+	string known_[] = {
+		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
+		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
+		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
+		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
+		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
+		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
+		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
+		"NNNNNNNNNNNNNNNNNNNNNNN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NNNNNNNNNNNNNN",
+		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
+		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
+		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
+		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
+		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
+	};
+	  vector <string> known(known_, known_+sizeof(known_)/sizeof(*known_)); 
+	int _ = -1; 
+END
+CASE(6)
+	string known_[] = {"N"};
+	  vector <string> known(known_, known_+sizeof(known_)/sizeof(*known_)); 
+	int _ = 1; 
+END
+
+}
+// END CUT HERE

ADDED   SRM/505-U/1B.cpp
Index: SRM/505-U/1B.cpp
==================================================================
--- SRM/505-U/1B.cpp
+++ SRM/505-U/1B.cpp
@@ -0,0 +1,156 @@
+#include <iostream>
+#include <sstream>
+#include <iomanip>
+#include <vector>
+#include <string>
+#include <map>
+#include <set>
+#include <algorithm>
+#include <numeric>
+#include <iterator>
+#include <functional>
+#include <complex>
+#include <queue>
+#include <stack>
+#include <cmath>
+#include <cassert>
+#include <cstring>
+using namespace std;
+typedef long long LL;
+typedef complex<double> CMP;
+
+class SetMultiples { public:
+	long long smallestSubset(long long A, long long B, long long C, long long D) 
+	{
+		vector< pair<LL,LL> > noneed( 1, make_pair(1,100000) );
+
+		LL cnt = 0;
+		for(LL p=1; p<=100000; ++p)
+		{
+			if( A<=p&&p<=B || C<=p&&p<=D )
+				if( need(p, A, B, C, D) )
+					++cnt;
+			if( p > 1 ) {
+				add(noneed, p, A, B);
+				add(noneed, p, C, D);
+			}
+		}
+		sort(noneed.begin(), noneed.end(), &my_order);
+		LL a = count_need(noneed, A, B);
+		LL b = count_need(noneed, C, D);
+		return cnt + a + b;
+	}
+
+	static bool need(LL p, LL A, LL B, LL C, LL D)
+	{
+		return !covered(p,A,B) && !covered(p,C,D);
+	}
+
+	static bool covered(LL p, LL A, LL B)
+	{
+		LL lo = A%p==0 ? A/p : A/p+1;
+		LL hi = B/p;
+		return ( lo<=hi && 2<=hi );
+	}
+
+	static void add(vector< pair<LL,LL> >& noneed, LL p, LL A, LL B)
+	{
+		LL lo = A%p==0 ? A/p : A/p+1;
+		LL hi = B/p;
+		if( lo <= hi )
+			noneed.push_back( make_pair(lo,hi) );
+	}
+
+	static bool my_order( const pair<LL,LL>& lhs, const pair<LL,LL>& rhs )
+	{
+		if( lhs.second != rhs.second )
+			return lhs.second > rhs.second;
+		return lhs.first < rhs.first;
+	}
+
+	static LL count_need(const vector< pair<LL,LL> >& noneed, LL A, LL B)
+	{
+		LL cnt = 0;
+		LL highest_need = B;
+		for(int i=0; i<noneed.size(); ++i)
+		{
+			LL lo = noneed[i].first;
+			LL hi = noneed[i].second;
+			if( hi < highest_need )
+				cnt += max(0LL, highest_need - max(hi,A-1));
+			highest_need = min(highest_need, lo-1);
+			if( highest_need < A )
+				return cnt;
+		}
+		return cnt + (highest_need - A + 1);
+	}
+};
+
+// BEGIN CUT HERE
+#include <ctime>
+double start_time; string timer()
+ { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
+template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
+ { os << "{ ";
+   for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
+   os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
+void verify_case(const long long& Expected, const long long& Received) {
+ bool ok = (Expected == Received);
+ if(ok) cerr << "PASSED" << timer() << endl;  else { cerr << "FAILED" << timer() << endl;
+ cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } }
+#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
+#define END	 verify_case(_, SetMultiples().smallestSubset(A, B, C, D));}
+int main(){
+
+CASE(0)
+	long long A = 1LL; 
+	long long B = 1LL; 
+	long long C = 2LL; 
+	long long D = 2LL; 
+	long long _ = 1LL; 
+END
+CASE(1)
+	long long A = 1LL; 
+	long long B = 2LL; 
+	long long C = 3LL; 
+	long long D = 4LL; 
+	long long _ = 2LL; 
+END
+CASE(2)
+	long long A = 2LL; 
+	long long B = 3LL; 
+	long long C = 5LL; 
+	long long D = 7LL; 
+	long long _ = 3LL; 
+END
+CASE(3)
+	long long A = 1LL; 
+	long long B = 10LL; 
+	long long C = 100LL; 
+	long long D = 1000LL; 
+	long long _ = 500LL; 
+END
+CASE(4)
+	long long A = 1000000000LL; 
+	long long B = 2000000000LL; 
+	long long C = 9000000000LL; 
+	long long D = 10000000000LL; 
+	long long _ = 1254365078LL; 
+END
+CASE(5)
+	long long A = 1LL; 
+	long long B = 1000000000LL; 
+	long long C = 2000000000LL; 
+	long long D = 10000000000LL; 
+	long long _ = -1LL; 
+END
+CASE(6)
+	long long A = 1LL; 
+	long long B = 2LL; 
+	long long C = 3LL; 
+	long long D = 5LL; 
+	long long _ = 3LL; 
+END
+
+}
+// END CUT HERE

DELETED SRM/505-u/1Au.cpp
Index: SRM/505-u/1Au.cpp
==================================================================
--- SRM/505-u/1Au.cpp
+++ SRM/505-u/1Au.cpp
@@ -1,170 +0,0 @@
-#include <iostream>
-#include <sstream>
-#include <iomanip>
-#include <vector>
-#include <string>
-#include <map>
-#include <set>
-#include <algorithm>
-#include <numeric>
-#include <iterator>
-#include <functional>
-#include <complex>
-#include <queue>
-#include <stack>
-#include <cmath>
-#include <cassert>
-#include <cstring>
-using namespace std;
-typedef long long LL;
-typedef complex<double> CMP;
-
-class RectangleArea { public:
-	int minimumQueries(vector <string> known) 
-	{
-		const int H = known.size();
-		const int W = known[0].size();
-		for(int y=0; y<H; ++y)
-		for(int x=0; x<W; ++x)
-		for(int Y=0; Y<H; ++Y)
-		for(int X=0; X<W; ++X)
-		if( make_pair(y,x) < make_pair(Y,X) && y!=Y && x!=X )
-		if( known[y][x]=='Y' && known[Y][X]=='Y' )
-		{
-			if( known[y][X]=='Y' )
-				known[Y][x] = 'Y';
-			if( known[Y][x]=='Y' )
-				known[y][X] = 'Y';
-		}
-
-		int tt = 0;
-		for(int i=0; i<W; ++i)
-			if( known[0][i]=='N' )
-				++tt;
-		int yy = 0;
-		for(int i=0; i<H; ++i)
-			if( known[i][0]=='N' )
-				++yy;
-		if( tt == 0 )
-			return yy;
-		if( yy == 0 )
-			return tt;
-		return -1;	
-	}
-};
-
-// BEGIN CUT HERE
-#include <ctime>
-double start_time; string timer()
- { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
-template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
- { os << "{ ";
-   for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
-   os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
-void verify_case(const int& Expected, const int& Received) {
- bool ok = (Expected == Received);
- if(ok) cerr << "PASSED" << timer() << endl;  else { cerr << "FAILED" << timer() << endl;
- cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } }
-#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
-#define END	 verify_case(_, RectangleArea().minimumQueries(known));}
-int main(){
-
-CASE(0)
-	string known_[] = {"NN",
- "NN"};
-	  vector <string> known(known_, known_+sizeof(known_)/sizeof(*known_)); 
-	int _ = 3; 
-END
-CASE(1)
-	string known_[] = {"YNY",
- "NYN",
- "YNY"};
-	  vector <string> known(known_, known_+sizeof(known_)/sizeof(*known_)); 
-	int _ = 1; 
-END
-CASE(2)
-	string known_[] = {"YY",
- "YY",
- "YY",
- "YY"};
-	  vector <string> known(known_, known_+sizeof(known_)/sizeof(*known_)); 
-	int _ = 0; 
-END
-CASE(3)
-	string known_[] = {"NNNNNNNNNN"};
-	  vector <string> known(known_, known_+sizeof(known_)/sizeof(*known_)); 
-	int _ = 10; 
-END
-CASE(4)
-	string known_[] = {"NNYYYNN",
- "NNNNNYN",
- "YYNNNNY",
- "NNNYNNN",
- "YYNNNNY"};
-	  vector <string> known(known_, known_+sizeof(known_)/sizeof(*known_)); 
-	int _ = 2; 
-END
-CASE(5)
-	string known_[] = {
-		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
-		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
-		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
-		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
-		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
-		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
-		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
-		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
-		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
-		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
-		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
-		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
-		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
-		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
-		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
-		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN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NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
-		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
-		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
-		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
-		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
-		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
-		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
-		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
-		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
-		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
-		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
-		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
-		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
-		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
-		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
-		"NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN",
-	};
-	  vector <string> known(known_, known_+sizeof(known_)/sizeof(*known_)); 
-	int _ = -1; 
-END
-CASE(6)
-	string known_[] = {"N"};
-	  vector <string> known(known_, known_+sizeof(known_)/sizeof(*known_)); 
-	int _ = 1; 
-END
-
-}
-// END CUT HERE

DELETED SRM/505-u/1B.cpp
Index: SRM/505-u/1B.cpp
==================================================================
--- SRM/505-u/1B.cpp
+++ SRM/505-u/1B.cpp
@@ -1,156 +0,0 @@
-#include <iostream>
-#include <sstream>
-#include <iomanip>
-#include <vector>
-#include <string>
-#include <map>
-#include <set>
-#include <algorithm>
-#include <numeric>
-#include <iterator>
-#include <functional>
-#include <complex>
-#include <queue>
-#include <stack>
-#include <cmath>
-#include <cassert>
-#include <cstring>
-using namespace std;
-typedef long long LL;
-typedef complex<double> CMP;
-
-class SetMultiples { public:
-	long long smallestSubset(long long A, long long B, long long C, long long D) 
-	{
-		vector< pair<LL,LL> > noneed( 1, make_pair(1,100000) );
-
-		LL cnt = 0;
-		for(LL p=1; p<=100000; ++p)
-		{
-			if( A<=p&&p<=B || C<=p&&p<=D )
-				if( need(p, A, B, C, D) )
-					++cnt;
-			if( p > 1 ) {
-				add(noneed, p, A, B);
-				add(noneed, p, C, D);
-			}
-		}
-		sort(noneed.begin(), noneed.end(), &my_order);
-		LL a = count_need(noneed, A, B);
-		LL b = count_need(noneed, C, D);
-		return cnt + a + b;
-	}
-
-	static bool need(LL p, LL A, LL B, LL C, LL D)
-	{
-		return !covered(p,A,B) && !covered(p,C,D);
-	}
-
-	static bool covered(LL p, LL A, LL B)
-	{
-		LL lo = A%p==0 ? A/p : A/p+1;
-		LL hi = B/p;
-		return ( lo<=hi && 2<=hi );
-	}
-
-	static void add(vector< pair<LL,LL> >& noneed, LL p, LL A, LL B)
-	{
-		LL lo = A%p==0 ? A/p : A/p+1;
-		LL hi = B/p;
-		if( lo <= hi )
-			noneed.push_back( make_pair(lo,hi) );
-	}
-
-	static bool my_order( const pair<LL,LL>& lhs, const pair<LL,LL>& rhs )
-	{
-		if( lhs.second != rhs.second )
-			return lhs.second > rhs.second;
-		return lhs.first < rhs.first;
-	}
-
-	static LL count_need(const vector< pair<LL,LL> >& noneed, LL A, LL B)
-	{
-		LL cnt = 0;
-		LL highest_need = B;
-		for(int i=0; i<noneed.size(); ++i)
-		{
-			LL lo = noneed[i].first;
-			LL hi = noneed[i].second;
-			if( hi < highest_need )
-				cnt += max(0LL, highest_need - max(hi,A-1));
-			highest_need = min(highest_need, lo-1);
-			if( highest_need < A )
-				return cnt;
-		}
-		return cnt + (highest_need - A + 1);
-	}
-};
-
-// BEGIN CUT HERE
-#include <ctime>
-double start_time; string timer()
- { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
-template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
- { os << "{ ";
-   for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
-   os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
-void verify_case(const long long& Expected, const long long& Received) {
- bool ok = (Expected == Received);
- if(ok) cerr << "PASSED" << timer() << endl;  else { cerr << "FAILED" << timer() << endl;
- cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } }
-#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
-#define END	 verify_case(_, SetMultiples().smallestSubset(A, B, C, D));}
-int main(){
-
-CASE(0)
-	long long A = 1LL; 
-	long long B = 1LL; 
-	long long C = 2LL; 
-	long long D = 2LL; 
-	long long _ = 1LL; 
-END
-CASE(1)
-	long long A = 1LL; 
-	long long B = 2LL; 
-	long long C = 3LL; 
-	long long D = 4LL; 
-	long long _ = 2LL; 
-END
-CASE(2)
-	long long A = 2LL; 
-	long long B = 3LL; 
-	long long C = 5LL; 
-	long long D = 7LL; 
-	long long _ = 3LL; 
-END
-CASE(3)
-	long long A = 1LL; 
-	long long B = 10LL; 
-	long long C = 100LL; 
-	long long D = 1000LL; 
-	long long _ = 500LL; 
-END
-CASE(4)
-	long long A = 1000000000LL; 
-	long long B = 2000000000LL; 
-	long long C = 9000000000LL; 
-	long long D = 10000000000LL; 
-	long long _ = 1254365078LL; 
-END
-CASE(5)
-	long long A = 1LL; 
-	long long B = 1000000000LL; 
-	long long C = 2000000000LL; 
-	long long D = 10000000000LL; 
-	long long _ = -1LL; 
-END
-CASE(6)
-	long long A = 1LL; 
-	long long B = 2LL; 
-	long long C = 3LL; 
-	long long D = 5LL; 
-	long long _ = 3LL; 
-END
-
-}
-// END CUT HERE