#include "mining.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define maxN 250005
#define MOD 1000
#define oo 1000000000000000007LL
#define sz(a) (int)a.size()
const double PI = acos(-1.0);
double fRand(double fMin, double fMax)
{
double f = (double)rand() / RAND_MAX;
return fMin + f * (fMax - fMin);
}
template <class T>
T min(T a, T b, T c) {
return min(a, min(b, c));
}
template <class T>
T max(T a, T b, T c) {
return max(a, max(b, c));
}
int sqr(int x) {return x*x;}
bool isSqr(int x) {
int y = sqrt(x);
return (y*y == x);
}
void findGold() {
// answer(2, 4);
int maxX = 1000;
vector<bool> res(maxX+1, false);
int cntInteger = 0;
fto(x, 1, maxX) {
res[x] = isIntegerDistance(x, x);
if (res[x]) ++cntInteger;
}
fto(x, 1, maxX) {
fto(y, 1, maxX) {
if (res[x] && res[y]) {
bool ok = true;
fto(z, 1, maxX) {
if (isSqr(sqr(x-z) + sqr(y-z))^res[z]) {
ok = false;
break;
}
}
if (ok) {
if (isIntegerDistance(x, y))
answer(x, y);
else
answer(y, x);
return;
}
}
}
}
}
I2luY2x1ZGUgIm1pbmluZy5oIgoKI2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKdHlwZWRlZiBsb25nIGxvbmcgbGw7CnR5cGVkZWYgY29tcGxleDxkb3VibGU+IHBvaW50OwojZGVmaW5lIG1hcGlpIG1hcDxpbnQsIGludD4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ClQgbWluKFQgYSwgVCBiLCBUIGMpIHsKICAgIHJldHVybiBtaW4oYSwgbWluKGIsIGMpKTsKfQoKdGVtcGxhdGUgPGNsYXNzIFQ+ClQgbWF4KFQgYSwgVCBiLCBUIGMpIHsKICAgIHJldHVybiBtYXgoYSwgbWF4KGIsIGMpKTsKfQoKaW50IHNxcihpbnQgeCkge3JldHVybiB4Kng7fQoKYm9vbCBpc1NxcihpbnQgeCkgewogICAgaW50IHkgPSBzcXJ0KHgpOwogICAgcmV0dXJuICh5KnkgPT0geCk7Cn0KCnZvaWQgZmluZEdvbGQoKSB7Ci8vICAgIGFuc3dlcigyLCA0KTsKICAgIGludCBtYXhYID0gMTAwMDsKICAgIHZlY3Rvcjxib29sPiByZXMobWF4WCsxLCBmYWxzZSk7CgogICAgaW50IGNudEludGVnZXIgPSAwOwogICAgZnRvKHgsIDEsIG1heFgpIHsKICAgICAgICByZXNbeF0gPSBpc0ludGVnZXJEaXN0YW5jZSh4LCB4KTsKICAgICAgICBpZiAocmVzW3hdKSArK2NudEludGVnZXI7CiAgICB9CgogICAgZnRvKHgsIDEsIG1heFgpIHsKICAgICAgICBmdG8oeSwgMSwgbWF4WCkgewogICAgICAgICAgICBpZiAocmVzW3hdICYmIHJlc1t5XSkgewogICAgICAgICAgICAgICAgYm9vbCBvayA9IHRydWU7CiAgICAgICAgICAgICAgICBmdG8oeiwgMSwgbWF4WCkgewogICAgICAgICAgICAgICAgICAgIGlmIChpc1NxcihzcXIoeC16KSArIHNxcih5LXopKV5yZXNbel0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgb2sgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKG9rKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKGlzSW50ZWdlckRpc3RhbmNlKHgsIHkpKQogICAgICAgICAgICAgICAgICAgICAgICBhbnN3ZXIoeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgICAgICBhbnN3ZXIoeSwgeCk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQp9Cg==