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 <set>
#include <map>
#include <ctime>
#include <cmath>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define lowbit(x) (x&(-x))
#define PII pair<LL,LL>
#define FOR(i,a,b) for (LL i=(a);i<=(b);++i)
#define ROF(i,b,a) for (LL i=(b);i>=(a);--i)
typedef long long LL;
inline LL read(){
	LL x=0,f=1; char ch=getchar();
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return x*f;
}

const LL MAXN=500005,lx=50000;
LL n,m,x,y,z,a,b;
LL exgcd(LL x,LL y,LL &a,LL &b){
	if (y==0) { a=1; b=0; return x; }
	LL tmp=exgcd(y,x%y,b,a); b-=a*(x/y); return tmp;
}
int main(){
	n=read();
	while (n--) {
		x=read(); y=read(); z=exgcd(x,y,a,b);
		//cout<<a<<' '<<b<<endl;
		if (a<0) a=-a; else if (b<0) b=-b;
		if (z<=lx) printf("3\n0 0\n%lld %lld\n%lld %lld\n",x,y,b,a);
		else printf("4\n0 0\n%lld %lld\n%lld %lld\n%lld %lld\n",x,y-1,x/z,y/z,x-1,y);
	}
	return 0;
}

/*
1
50001 50001

*/