Problem: Example

Input

2
5 6
1000000000 2


Output

4
5 6
0 6
0 0
5 0
3
1000000000 0
0 2
999999999 0

Solution (in CPP):

Solution:
#include <cmath>
#include <iostream>
using namespace std;
long long extgcd(long long a, long long b, long long &x, long long &y) {
	long long g = a;
	x = 1, y = 0;
	if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
	return g;
}
int main() {
	int q;
	cin >> q;
	for (int i = 0; i < q; ++i) {
		long long px, py, qx, qy;
		cin >> px >> py;
		long long g = extgcd(px, py, qy, qx);
		if (g <= 50000) {
			cout << 3 << endl;
			cout << 0 << ' ' << 0 << endl;
			cout << px << ' ' << py << endl;
			cout << abs(qx) << ' ' << abs(qy) << endl;
		}
		else {
			cout << 4 << endl;
			cout << 1 << ' ' << 0 << endl;
			cout << px << ' ' << py << endl;
			cout << 0 << ' ' << 1 << endl;
			cout << px / g * (g - 1) << ' ' << py / g * (g - 1) << endl;
		}
	}
	return 0;
}