#include <sstream>
#include <fstream>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <utility>
#include <cassert>
#include <bitset>
using namespace std;
#define REP(I,N) for (I=0;I<N;I++)
#define rREP(I,N) for (I=N-1;I>=0;I--)
#define rep(I,S,N) for (I=S;I<N;I++)
#define rrep(I,S,N) for (I=N-1;I>=S;I--)
#define FOR(I,S,N) for (I=S;I<=N;I++)
#define rFOR(I,S,N) for (I=N;I>=S;I--)

#define DEBUG
#ifdef DEBUG
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define deputs(str) fprintf(stderr, "%s\n",str)
#else
#define debug(...)
#define deputs(str)
#endif // DEBUG
typedef unsigned long long ULL;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef long long LL;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF=0x3f3f3f3f;
const LL INFF=0x3f3f3f3f3f3f3f3fll;
const LL M=1e9+7;
const LL maxn=4e5+107;
const double pi=acos(-1.0);
const double eps=0.0000000001;
LL gcd(LL a, LL b) {return b?gcd(b,a%b):a;}
template<typename T>inline void pr2(T x,int k=64) {ll i; REP(i,k) debug("%d",(x>>i)&1); putchar(' ');}
template<typename T>inline void add_(T &A,int B,ll MOD=M) {A+=B; (A>=MOD) &&(A-=MOD);}
template<typename T>inline void mul_(T &A,ll B,ll MOD=M) {A=(A*B)%MOD;}
template<typename T>inline void mod_(T &A,ll MOD=M) {A%=MOD; A+=MOD; A%=MOD;}
template<typename T>inline void max_(T &A,T B) {(A<B) &&(A=B);}
template<typename T>inline void min_(T &A,T B) {(A>B) &&(A=B);}
template<typename T>inline T abs(T a) {return a>0?a:-a;}
template<typename T>inline T powMM(T a, T b) {
	T ret=1;
	for (; b; b>>=1ll,a=(LL)a*a%M)
		if (b&1) ret=(LL)ret*a%M;
	return ret;
}
int startTime;
void startTimer() {startTime=clock();}
void printTimer() {debug("/--- Time: %ld milliseconds ---/\n",clock()-startTime);}

int a[maxn],b[maxn],c[maxn];
//差分后相当
int value[maxn];//count
queue<pair<int,int> > Q;
int main() {
	int n,i,j;
	scanf("%d",&n);
	FOR(i,1,n) scanf("%1d",&a[i]),c[i]=a[i];
	FOR(i,1,n) scanf("%1d",&b[i]);
	FOR(i,1,n-1) {
		if (c[i]!=b[i]) {
			if (c[i]<b[i]) {
				REP(j,b[i]-c[i]) Q.push(make_pair(i,1));
				// printf("%d :+ %d\n",i,b[i]-c[i]);
				c[i+1]+=b[i]-c[i]; c[i]+=b[i]-c[i];
			} else {
				REP(j,c[i]-b[i]) Q.push(make_pair(i,-1));
				// printf("%d :- %d\n",i,c[i]-b[i]);
				c[i+1]-=c[i]-b[i]; c[i]-=c[i]-b[i];
			}
		}
	}
	if (c[n]!=b[n]) return 0*puts("-1");
	else {
		int c=1e5;
		printf("%d\n",(int)Q.size());
		while (Q.size()) {
			auto now=Q.front(); Q.pop();
			if (0<=a[now.first]+now.second&&a[now.first]+now.second<=9&&
				0<=a[now.first+1]+now.second&&a[now.first+1]+now.second<=9){
				a[now.first]+=now.second; a[now.first+1]+=now.second;
			} else Q.push(now);
			printf("%d %d\n",now.first,now.second);
			c--; if (!c) return 0;
		}
	}
}
/*
*/


#include <sstream>
#include <fstream>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <utility>
#include <cassert>
#include <bitset>
using namespace std;
#define REP(I,N) for (I=0;I<N;I++)
#define rREP(I,N) for (I=N-1;I>=0;I--)
#define rep(I,S,N) for (I=S;I<N;I++)
#define rrep(I,S,N) for (I=N-1;I>=S;I--)
#define FOR(I,S,N) for (I=S;I<=N;I++)
#define rFOR(I,S,N) for (I=N;I>=S;I--)

#define DEBUG
#ifdef DEBUG
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define deputs(str) fprintf(stderr, "%s\n",str)
#else
#define debug(...)
#define deputs(str)
#endif // DEBUG
typedef unsigned long long ULL;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef long long LL;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF=0x3f3f3f3f;
const LL INFF=0x3f3f3f3f3f3f3f3fll;
const LL M=1e9+7;
const LL maxn=1e5+107;
const double pi=acos(-1.0);
const double eps=0.0000000001;
LL gcd(LL a, LL b) {return b?gcd(b,a%b):a;}
template<typename T>inline void pr2(T x,int k=64) {ll i; REP(i,k) debug("%d",(x>>i)&1); putchar(' ');}
template<typename T>inline void add_(T &A,int B,ll MOD=M) {A+=B; (A>=MOD) &&(A-=MOD);}
template<typename T>inline void mul_(T &A,ll B,ll MOD=M) {A=(A*B)%MOD;}
template<typename T>inline void mod_(T &A,ll MOD=M) {A%=MOD; A+=MOD; A%=MOD;}
template<typename T>inline void max_(T &A,T B) {(A<B) &&(A=B);}
template<typename T>inline void min_(T &A,T B) {(A>B) &&(A=B);}
template<typename T>inline T abs(T a) {return a>0?a:-a;}
template<typename T>inline T powMM(T a, T b) {
	T ret=1;
	for (; b; b>>=1ll,a=(LL)a*a%M)
		if (b&1) ret=(LL)ret*a%M;
	return ret;
}
int startTime;
void startTimer() {startTime=clock();}
void printTimer() {debug("/--- Time: %ld milliseconds ---/\n",clock()-startTime);}

int a[maxn],b[maxn];
ll c[maxn],d[maxn],msk[maxn];
//差分后相当
ll all=0;
queue<int> Q;
int main() {
	int n,i;
	scanf("%d",&n);
	FOR(i,1,n) scanf("%1d",&a[i]),c[i]=a[i];
	FOR(i,1,n) scanf("%1d",&b[i]);
	FOR(i,1,n-1) {
		if (c[i]!=b[i]) {
			if (c[i]<b[i]) {
				all+=d[i]=b[i]-c[i]; msk[i]=1; Q.push(i);
				// printf("%d :+ %d\n",i,b[i]-c[i]);
				c[i+1]+=b[i]-c[i]; c[i]+=b[i]-c[i];
			} else {//c[i]>b[i]
				// printf("%d :- %d\n",i,c[i]-b[i]);
				all+=d[i]=c[i]-b[i]; msk[i]=-1; Q.push(i);
				c[i+1]-=c[i]-b[i]; c[i]-=c[i]-b[i];
			}
		}
	}
	// printf("%lld %d\n",c[n],b[n]);
	if (c[n]!=b[n]) return 0*puts("-1");
	else {
		int c=100000;
		printf("%lld\n",all);
		while (Q.size()) {
			auto now=Q.front(); Q.pop();
			if (0+(now==1)<=a[now]+msk[now]&&a[now]+msk[now]<=9&&
				0<=a[now+1]+msk[now]&&a[now+1]+msk[now]<=9){
				a[now]+=msk[now]; a[now+1]+=msk[now]; d[now]--;
				printf("%d %lld\n",now,msk[now]);
				// printf("toward %d %d\n",a[now],a[now+1]);
				c--; if (!c) return 0;
			} if (d[now]) Q.push(now);
		}
	}
}
/*
22
9090909090990909090909
0909090909009090909090
*/


#include <cstdio>
#include <cstring>
#include <cstdlib>
using namespace std;
long long abs(long long x){return (x>0?x:(-x));}
char ch[100010];
int a[100010],b[100010];
int nowa[100010],ned[100010];
int w[2000010],d[2000010];
long long now=0,cost;
void dfs(int x,int v)
{
	if(v==1)
	{
		if(a[x+1]==9) dfs(x+1,-1);
	}else
	{
		if(a[x+1]==0) dfs(x+1,1);
	}
	a[x]+=v;a[x+1]+=v;
	printf("%d %d\n",x,v);
	now++;
	if(now==cost||now==100000) exit(0);
}
int main()
{
	//freopen("Once.in","r",stdin);
	//freopen("Once.out","w",stdout);
	int n,i,j,nowv,nowc;bool bz;
	scanf("%d",&n);
	scanf("%s",ch+1);
	for(i=1;i<=n;i++) nowa[i]=a[i]=(ch[i]-'0');
	scanf("%s",ch+1);
	for(i=1;i<=n;i++) b[i]=ch[i]-'0';
	for(i=1;i<n;i++)
	{
		ned[i]=b[i]-nowa[i];
		nowa[i+1]+=ned[i];
		cost+=abs(ned[i]);
	}
	//printf("%d\n",nowa[n]);
	if(nowa[n]!=b[n]) {printf("-1\n");return 0;}
	nowc=0;
	printf("%lld\n",cost);
	for(i=1;i<n;i++)
	{
		while(a[i]<b[i]) dfs(i,1);
		while(a[i]>b[i]) dfs(i,-1);
	}
	return 0;
}


/**************************************************************
    Problem: ????
    User: Big_Red_Dates
    Language: GNU_C++11
    Result: Accepted
    Time:0 ms
    Memory:0 kb
    length:0 kb
    score: inf
****************************************************************/
//CLOCKS_PER_SEC
using namespace std;
#include<bitset>
#include<deque>
#include<stdint.h>
#include<set>
#include<stack>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
#include<ctime>
#include<map>
#define sqr(x) (x)*(x)
#define sort stable_sort
#define ll long long
#define mk make_pair
#define pb push_back
#define in insert
#define mtr(x,y,z) mk(mk(x,y),z)
#define fi first
#define se second
#define lch(x) ((x)<<1)
#define rch(x) (((x)<<1)|1)
#define all(x) (x).begin(),(x).end()
#define titose CLOCKS_PER_SEC
#define fpi(x) freopen(x,"r",stdin);
#define fpo(x) freopen(x,"w",stdout);
#define fprio fpi("in.txt");fpo("out.txt");
#define fast ios_base::sync_with_stdio(false);
inline void read(int &x){int v=0,f=1;char c=getchar();while (!isdigit(c)&&c!='-') c=getchar();if (c=='-') f=-1; else v=v*10+c-'0';while (isdigit(c=getchar())) v=v*10+c-'0';x=v*f;}
inline void read(ll &x){ll v=0ll,f=1ll;char c=getchar();while (!isdigit(c)&&c!='-') c=getchar();if (c=='-') f=-1; else v=v*10+c-'0';while (isdigit(c=getchar())) v=v*10+c-'0';x=v*f;}
inline void readc(char &x){char c;while ((c=getchar())==' ');x=c;}
inline void writes(string s){puts(s.c_str());}
inline void writeln(){writes("");}
inline void writei(int x){if (x<0){putchar('-');x=abs(x);}if (!x) putchar('0');char a[25];int top=0;while (x){a[++top]=(x%10)+'0';x/=10;}while (top){putchar(a[top]);top--;}}
inline void writell(ll x){if (x<0){putchar('-');x=abs(x);}if (!x) putchar('0');char a[25];int top=0;while (x){a[++top]=(x%10)+'0';x/=10;}while (top){putchar(a[top]);top--;}}
/*
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#pragma GCC optimize(5)
#pragma GCC optimize(6)
#pragma GCC optimize(7)
#pragma GCC optimize(8)
#pragma GCC optimize(9)
*/
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define si set<int>
#define sl set<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define msi map<string,int>
#define msl map<string,ll>
#define piii pair<int,pii >
#define piipi pair<pii,int>
#define plll pair<ll,pll >
#define pllpl pair<pll,ll>
#define pqi priority_queue<int>
#define pql priority_queue<ll>
#define npqi priority_queue<int,vector<int>,greater<int> >
#define npql priority_queue<ll,vector<ll>,greater<ll> >
#define forup(i,csc,lys) for ((i)=(csc);(i)<=(lys);(i)++)
#define fordo(i,csc,lys) for ((i)=(csc);(i)>=(lys);(i)--)
#define rep(i,x) forup ((i),1,(x))
#define repd(i,x) fordo ((i),(x),1)
#define itr iterator
#define lyscsc(itcalc,c) for(__typeof((c).begin()) itcalc=(c).begin();itcalc!=(c).end();itcalc++)
#define NO {cout<<"-1";return 0;}
#define YES {cout<<"YES";return 0;}
#define y0 y000000000000000000000000000
#define y1 y111111111111111111111111111
#define j0 j000000000000000000000000000
#define j1 j111111111111111111111111111
#define cl0(a) memset((a),(0),(sizeof((a))))
#define clz(a) memset((a),(0x16),(sizeof((a))))
#define clf(a) memset((a),(-(0x16)),(sizeof((a))))
#define inf 0x3bbbbbbb
#define lnf 0x1bbbbbbbbbbbbbbbll
#define sqrt divi
#define p2(i) (1ll<<(i))
#define readi read
#define readll read
/*************************************************/
int n,m,i,j,dp[100005][10],pre[100005][10],a[100005],b[100005];
string s,t;
vector<int> s1,s2;
int f(int x,int y,bool lys)
{
	if (lys)
	{
		return max(abs(y-x),10-abs(y-x));
	}
	else
	{
		return abs(y-x);
	}
}
int g(int fx,int tx,int fy)
{
	int t=(tx-fx+10)%10;
	return (fy+t)%10;
}
int h(int fx,int tx)
{
	return (tx-fx+10)%10;
}
void print()
{
	printf("%d\n",s1.size());
	int i;
	forup(i,0,min(9999,((int)s1.size())-1))
	{
		printf("%d %d\n",s1[i],s2[i]);
	}
}
void inc(int &x){x=(x+1)%10;}
void dec(int &x){x=(x+10-1)%10;}
int main()
{
	fast;
	cin>>n>>s>>t;s=" "+s;t=" "+t;
	if (n==2) if (h(s[1]-'0',t[1]-'0')!=h(s[2]-'0',t[2]-'0')) {puts("-1");return 0;}
	else
	{
		while (s[1]-'0'<t[1]-'0') {s1.pb(1);s2.pb(1);s[1]++;}
		while (s[1]-'0'>t[1]-'0') {s1.pb(1);s2.pb(-1);s[1]--;}
		print();
		return 0;
	}
	rep(i,n) {a[i]=s[i]-'0';b[i]=t[i]-'0';}
	while (a[1]<b[1]) {s1.pb(1);s2.pb(1);inc(a[1]);inc(a[1+1]);}
	while (a[1]>b[1]) {s1.pb(1);s2.pb(-1);dec(a[1]);dec(a[1+1]);}
	forup(i,2,n-1)
	{
		if ((abs(a[i]-b[i])<10-abs(a[i]-b[i]))^(a[i]<b[i]))
		{
			while (a[i]!=b[i]) {s1.pb(i);s2.pb(-1);dec(a[i]);dec(a[i+1]);}
		}
		else
		{
			while (a[i]!=b[i]) {s1.pb(i);s2.pb(1);inc(a[i]);inc(a[i+1]);}
		}
	}
	if (a[n]==b[n]) print(); else puts("-1");
	return 0;
}


/**************************************************************
    Problem: ????
    User: Big_Red_Dates
    Language: GNU_C++11
    Result: Accepted
    Time:0 ms
    Memory:0 kb
    length:0 kb
    score: inf
****************************************************************/
//CLOCKS_PER_SEC
using namespace std;
#include<bitset>
#include<deque>
#include<stdint.h>
#include<set>
#include<stack>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
#include<ctime>
#include<map>
#define sqr(x) (x)*(x)
#define sort stable_sort
#define ll long long
#define mk make_pair
#define pb push_back
#define in insert
#define mtr(x,y,z) mk(mk(x,y),z)
#define fi first
#define se second
#define lch(x) ((x)<<1)
#define rch(x) (((x)<<1)|1)
#define all(x) (x).begin(),(x).end()
#define titose CLOCKS_PER_SEC
#define fpi(x) freopen(x,"r",stdin);
#define fpo(x) freopen(x,"w",stdout);
#define fprio fpi("in.txt");fpo("out.txt");
#define fast ios_base::sync_with_stdio(false);
inline void read(int &x){int v=0,f=1;char c=getchar();while (!isdigit(c)&&c!='-') c=getchar();if (c=='-') f=-1; else v=v*10+c-'0';while (isdigit(c=getchar())) v=v*10+c-'0';x=v*f;}
inline void read(ll &x){ll v=0ll,f=1ll;char c=getchar();while (!isdigit(c)&&c!='-') c=getchar();if (c=='-') f=-1; else v=v*10+c-'0';while (isdigit(c=getchar())) v=v*10+c-'0';x=v*f;}
inline void readc(char &x){char c;while ((c=getchar())==' ');x=c;}
inline void writes(string s){puts(s.c_str());}
inline void writeln(){writes("");}
inline void writei(int x){if (x<0){putchar('-');x=abs(x);}if (!x) putchar('0');char a[25];int top=0;while (x){a[++top]=(x%10)+'0';x/=10;}while (top){putchar(a[top]);top--;}}
inline void writell(ll x){if (x<0){putchar('-');x=abs(x);}if (!x) putchar('0');char a[25];int top=0;while (x){a[++top]=(x%10)+'0';x/=10;}while (top){putchar(a[top]);top--;}}
/*
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#pragma GCC optimize(5)
#pragma GCC optimize(6)
#pragma GCC optimize(7)
#pragma GCC optimize(8)
#pragma GCC optimize(9)
*/
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define si set<int>
#define sl set<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define msi map<string,int>
#define msl map<string,ll>
#define piii pair<int,pii >
#define piipi pair<pii,int>
#define plll pair<ll,pll >
#define pllpl pair<pll,ll>
#define pqi priority_queue<int>
#define pql priority_queue<ll>
#define npqi priority_queue<int,vector<int>,greater<int> >
#define npql priority_queue<ll,vector<ll>,greater<ll> >
#define forup(i,csc,lys) for ((i)=(csc);(i)<=(lys);(i)++)
#define fordo(i,csc,lys) for ((i)=(csc);(i)>=(lys);(i)--)
#define rep(i,x) forup ((i),1,(x))
#define repd(i,x) fordo ((i),(x),1)
#define itr iterator
#define lyscsc(itcalc,c) for(__typeof((c).begin()) itcalc=(c).begin();itcalc!=(c).end();itcalc++)
#define NO {cout<<"-1";return 0;}
#define YES {cout<<"YES";return 0;}
#define y0 y000000000000000000000000000
#define y1 y111111111111111111111111111
#define j0 j000000000000000000000000000
#define j1 j111111111111111111111111111
#define cl0(a) memset((a),(0),(sizeof((a))))
#define clz(a) memset((a),(0x16),(sizeof((a))))
#define clf(a) memset((a),(-(0x16)),(sizeof((a))))
#define inf 0x3bbbbbbb
#define lnf 0x1bbbbbbbbbbbbbbbll
#define sqrt divi
#define p2(i) (1ll<<(i))
#define readi read
#define readll read
/*************************************************/
int n,m,i,j,dp[100005][10],pre[100005][10],a[100005],b[100005];
string s,t;
vector<int> s1,s2;
int f(int x,int y,bool lys)
{
	if (lys)
	{
		return max(abs(y-x),10-abs(y-x));
	}
	else
	{
		return abs(y-x);
	}
}
int g(int fx,int tx,int fy)
{
	int t=(tx-fx+10)%10;
	return (fy+t)%10;
}
int h(int fx,int tx)
{
	return (tx-fx+10)%10;
}
void print()
{
	printf("%d\n",s1.size());
	int i;
	forup(i,0,min(99999,((int)s1.size())-1))
	{
		printf("%d %d\n",s1[i],s2[i]);
	}
}
void inc(int &x){x=(x+1)%10;}
void dec(int &x){x=(x+10-1)%10;}
int main()
{
	fast;
	cin>>n>>s>>t;s=" "+s;t=" "+t;
	if (n==2) if (h(s[1]-'0',t[1]-'0')!=h(s[2]-'0',t[2]-'0')) {puts("-1");return 0;}
	else
	{
		while (s[1]-'0'<t[1]-'0') {s1.pb(1);s2.pb(1);s[1]++;}
		while (s[1]-'0'>t[1]-'0') {s1.pb(1);s2.pb(-1);s[1]--;}
		print();
		return 0;
	}
	rep(i,n) {a[i]=s[i]-'0';b[i]=t[i]-'0';}
	while (a[1]<b[1]) {s1.pb(1);s2.pb(1);inc(a[1]);inc(a[1+1]);}
	while (a[1]>b[1]) {s1.pb(1);s2.pb(-1);dec(a[1]);dec(a[1+1]);}
	forup(i,2,n-1)
	{
		if ((abs(a[i]-b[i])<10-abs(a[i]-b[i]))^(a[i]<b[i]))
		{
			while (a[i]!=b[i]) {s1.pb(i);s2.pb(-1);dec(a[i]);dec(a[i+1]);}
		}
		else
		{
			while (a[i]!=b[i]) {s1.pb(i);s2.pb(1);inc(a[i]);inc(a[i+1]);}
		}
	}
	if (a[n]==b[n]) print(); else puts("-1");
	return 0;
}


/**************************************************************
    Problem: ????
    User: Big_Red_Dates
    Language: GNU_C++11
    Result: Accepted
    Time:0 ms
    Memory:0 kb
    length:0 kb
    score: inf
****************************************************************/
//CLOCKS_PER_SEC
using namespace std;
#include<bitset>
#include<deque>
#include<stdint.h>
#include<set>
#include<stack>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
#include<ctime>
#include<map>
#define sqr(x) (x)*(x)
#define sort stable_sort
#define ll long long
#define mk make_pair
#define pb push_back
#define in insert
#define mtr(x,y,z) mk(mk(x,y),z)
#define fi first
#define se second
#define lch(x) ((x)<<1)
#define rch(x) (((x)<<1)|1)
#define all(x) (x).begin(),(x).end()
#define titose CLOCKS_PER_SEC
#define fpi(x) freopen(x,"r",stdin);
#define fpo(x) freopen(x,"w",stdout);
#define fprio fpi("in.txt");fpo("out.txt");
#define fast ios_base::sync_with_stdio(false);
inline void read(int &x){int v=0,f=1;char c=getchar();while (!isdigit(c)&&c!='-') c=getchar();if (c=='-') f=-1; else v=v*10+c-'0';while (isdigit(c=getchar())) v=v*10+c-'0';x=v*f;}
inline void read(ll &x){ll v=0ll,f=1ll;char c=getchar();while (!isdigit(c)&&c!='-') c=getchar();if (c=='-') f=-1; else v=v*10+c-'0';while (isdigit(c=getchar())) v=v*10+c-'0';x=v*f;}
inline void readc(char &x){char c;while ((c=getchar())==' ');x=c;}
inline void writes(string s){puts(s.c_str());}
inline void writeln(){writes("");}
inline void writei(int x){if (x<0){putchar('-');x=abs(x);}if (!x) putchar('0');char a[25];int top=0;while (x){a[++top]=(x%10)+'0';x/=10;}while (top){putchar(a[top]);top--;}}
inline void writell(ll x){if (x<0){putchar('-');x=abs(x);}if (!x) putchar('0');char a[25];int top=0;while (x){a[++top]=(x%10)+'0';x/=10;}while (top){putchar(a[top]);top--;}}
/*
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#pragma GCC optimize(5)
#pragma GCC optimize(6)
#pragma GCC optimize(7)
#pragma GCC optimize(8)
#pragma GCC optimize(9)
*/
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define si set<int>
#define sl set<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define msi map<string,int>
#define msl map<string,ll>
#define piii pair<int,pii >
#define piipi pair<pii,int>
#define plll pair<ll,pll >
#define pllpl pair<pll,ll>
#define pqi priority_queue<int>
#define pql priority_queue<ll>
#define npqi priority_queue<int,vector<int>,greater<int> >
#define npql priority_queue<ll,vector<ll>,greater<ll> >
#define forup(i,csc,lys) for ((i)=(csc);(i)<=(lys);(i)++)
#define fordo(i,csc,lys) for ((i)=(csc);(i)>=(lys);(i)--)
#define rep(i,x) forup ((i),1,(x))
#define repd(i,x) fordo ((i),(x),1)
#define itr iterator
#define lyscsc(itcalc,c) for(__typeof((c).begin()) itcalc=(c).begin();itcalc!=(c).end();itcalc++)
#define NO {cout<<"-1";return 0;}
#define YES {cout<<"YES";return 0;}
#define y0 y000000000000000000000000000
#define y1 y111111111111111111111111111
#define j0 j000000000000000000000000000
#define j1 j111111111111111111111111111
#define cl0(a) memset((a),(0),(sizeof((a))))
#define clz(a) memset((a),(0x16),(sizeof((a))))
#define clf(a) memset((a),(-(0x16)),(sizeof((a))))
#define inf 0x3bbbbbbb
#define lnf 0x1bbbbbbbbbbbbbbbll
#define sqrt divi
#define p2(i) (1ll<<(i))
#define readi read
#define readll read
/*************************************************/
int n,m,i,j,a[100005],b[100005],d[100005],lys,csc;
long long ans;
string s,t;
void itcalc()
{
	for (;;)
	{
		if (d[lys])
		{
			if (d[lys]>0)
			{
				if (a[lys]<9&&a[lys+1]<9)
				{
					printf("%d %d\n",lys,1);
					a[lys]++;a[lys+1]++;
					d[lys]--;
					return;
				}
			}
			else
			{
				if (a[lys]>0&&a[lys+1]>0)
				{
					printf("%d %d\n",lys,-1);
					a[lys]--;a[lys+1]--;
					d[lys]++;
					return;
				}
			}
		}
		lys+=csc;
		if (lys>=n)
		{
			lys-=2;csc*=-1;
		}
		if (lys<1)
		{
			lys+=2;csc*=-1;
		}
	}
}
int main()
{
	fast;
	cin>>n>>s>>t;s=" "+s;t=" "+t;
	rep(i,n) {a[i]=s[i]-'0';b[i]=t[i]-'0';}
	rep(i,n) d[i]=b[i]-d[i-1]-a[i];
	if (d[n])
	{
		puts("-1");
		return 0;
	}
	rep(i,n) ans+=abs(d[i]);
	printf("%I64d\n",ans);
	ans=min(ans,100000ll);
	lys=csc=1;
	while (ans--) itcalc();
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define fr(i,x,y) for(int i=(x);i<=(y);i++)
#define rf(i,x,y) for(int i=(x);i>=(y);i--)
#define frl(i,x,y) for(int i=(x);i<(y);i++)
using namespace std;
const int N=100003;
const int M=N;
int n;
char ch[N];
int a[N],b[N];
int c[N];
vector<int> g[N];
queue<int> h;
int m,d[N],num[N];

void read(int &x){
	char ch=getchar();x=0;
	for(;ch<'0'||ch>'9';ch=getchar());
	for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<3)+(x<<1)+ch-'0';
}

inline int sign(int x){
	if (x==0) return 0;
	return x>0?1:-1;
}

void topsort(){
	frl(i,1,n) if (d[i]==0) h.push(i);
	while(!h.empty()){
		int x=h.front();h.pop();
		num[++m]=x;
		frl(i,0,g[x].size()){
			int tmp=g[x][i];
			if (--d[tmp]==0) h.push(tmp);
		}
	}
}

int main(){
	read(n);
	scanf("%s",ch+1);
	fr(i,1,n) a[i]=ch[i]-'0';
	scanf("%s",ch+1);
	fr(i,1,n) b[i]=ch[i]-'0';
	frl(i,1,n) c[i]=b[i]-(a[i]+c[i-1]);
	if (a[n]+c[n-1]!=b[n]) return printf("-1\n"),0;
	frl(i,2,n)
	 if (sign(c[i])!=sign(c[i-1])){
	 	if (a[i]+sign(c[i])>=0&&a[i]+sign(c[i])<=9){
	 		g[i].push_back(i-1);
	 		d[i-1]++;
	 	}else{
	 		g[i-1].push_back(i);
	 		d[i]++;
	 	}
	 }
	topsort();
	int s=0;
	frl(i,1,n) s+=abs(c[i]);
	printf("%d\n",s);
	s=0;
	fr(o,1,9)
	 frl(i,1,n)
	  if (s<100000&&abs(c[num[i]])>=o)
	   printf("%d %d\n",num[i],sign(c[num[i]])),s++;
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define fr(i,x,y) for(int i=(x);i<=(y);i++)
#define rf(i,x,y) for(int i=(x);i>=(y);i--)
#define frl(i,x,y) for(int i=(x);i<(y);i++)
using namespace std;
const int N=100003;
const int M=N;
int n;
char ch[N];
int a[N],b[N];
int c[N];
vector<int> g[N];
queue<int> h;
int m,d[N],num[N];

void read(int &x){
	char ch=getchar();x=0;
	for(;ch<'0'||ch>'9';ch=getchar());
	for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<3)+(x<<1)+ch-'0';
}

inline int sign(int x){
	if (x==0) return 0;
	return x>0?1:-1;
}

void topsort(){
	frl(i,1,n) if (d[i]==0) h.push(i);
	while(!h.empty()){
		int x=h.front();h.pop();
		num[++m]=x;
		frl(i,0,g[x].size()){
			int tmp=g[x][i];
			if (--d[tmp]==0) h.push(tmp);
		}
	}
}

int main(){
	read(n);
	scanf("%s",ch+1);
	fr(i,1,n) a[i]=ch[i]-'0';
	scanf("%s",ch+1);
	fr(i,1,n) b[i]=ch[i]-'0';
	frl(i,1,n) c[i]=b[i]-(a[i]+c[i-1]);
	if (a[n]+c[n-1]!=b[n]) return printf("-1\n"),0;
	frl(i,2,n)
	 if (sign(c[i])!=sign(c[i-1])){
	 	if (a[i]+sign(c[i])>=0&&a[i]+sign(c[i])<=9){
	 		g[i].push_back(i-1);
	 		d[i-1]++;
	 	}else{
	 		g[i-1].push_back(i);
	 		d[i]++;
	 	}
	 }
	topsort();
	ll s=0;int mx=0;
	frl(i,1,n) s+=abs(c[i]),mx=max(mx,abs(c[i]));
	printf("%lld\n",s);
	s=0;
	fr(o,1,mx)
	 frl(i,1,n)
	  if (s<100000&&abs(c[num[i]])>=o)
	   printf("%d %d\n",num[i],sign(c[num[i]])),s++;
	  else if (s>=100000) break;
	return 0;
}


#include <cstdio>
#include <cstring>
const int MAXN=110000;
const int LIM=1E5;
char a[MAXN], b[MAXN];
int m, op[MAXN], val[MAXN];
void decrease(int);
void increase(int p)
{
	if (a[p+1]=='9') decrease(p+1);
	a[p]++, a[p+1]++;
	if (++m<=LIM) op[m]=p, val[m]=1;
}
void decrease(int p)
{
	if (a[p+1]=='0') increase(p+1);
	a[p]--, a[p+1]--;
	if (++m<=LIM) op[m]=p, val[m]=-1;
}
int main()
{
//	freopen("B.in", "r", stdin);
//	freopen("B.out", "w", stdout);
	int n, d=0; m=0;
	scanf("%d%s%s", &n, a+1, b+1);
	for (int i=1; i<=n; i++)
		d+=n-i&1?b[i]-a[i]:a[i]-b[i];
	if (d!=0)
	{
		puts("-1");
		return 0;
	}
	for (int i=1; i<n; i++)
	{
		while (a[i]<b[i]) increase(i);
		while (a[i]>b[i]) decrease(i);
	}
	printf("%d\n", m);
	for (int i=1; i<=m&&i<=LIM; i++)
		printf("%d %d\n", op[i], val[i]);
	return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
const int MAXN=110000;
int cnt=100000;
char a[MAXN], b[MAXN], t[MAXN];
void decrease(int);
void increase(int p)
{
	if (a[p+1]=='9') decrease(p+1);
	a[p]++, a[p+1]++;
	if (cnt--) printf("%d 1\n", p);
	else exit(0);
}
void decrease(int p)
{
	if (a[p+1]=='0') increase(p+1);
	a[p]--, a[p+1]--;
	if (cnt--) printf("%d -1\n", p);
	else exit(0);
}
int main()
{
//	freopen("B.in", "r", stdin);
//	freopen("B.out", "w", stdout);
	int n, m=0;
	scanf("%d%s%s", &n, a+1, b+1);
	memcpy(t, a, sizeof a);
	for (int i=1; i<n; i++)
	{
		m+=abs(t[i]-b[i]);
		t[i+1]+=b[i]-t[i], t[i]=b[i];
	}
	if (t[n]!=b[n])
	{
		puts("-1");
		return 0;
	}
	printf("%d\n", m);
	for (int i=1; i<n; i++)
	{
		while (a[i]<b[i]) increase(i);
		while (a[i]>b[i]) decrease(i);
	}
	return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
const int MAXN=110000;
int cnt=100000;
char a[MAXN], b[MAXN], t[MAXN];
void increase(int);
void decrease(int);
void increase(int p)
{
	if (a[p+1]==9) decrease(p+1);
	a[p]++, a[p+1]++;
	if (cnt--) printf("%d 1\n", p);
	else exit(0);
}
void decrease(int p)
{
	if (a[p+1]==0) increase(p+1);
	a[p]--, a[p+1]--;
	if (cnt--) printf("%d -1\n", p);
	else exit(0);
}
int main()
{
//	freopen("B.in", "r", stdin);
//	freopen("B.out", "w", stdout);
	int n, m=0;
	scanf("%d%s%s", &n, a+1, b+1);
	memcpy(t, a, sizeof a);
	for (int i=1; i<n; i++)
	{
		m+=abs(t[i]-b[i]);
		t[i+1]+=b[i]-t[i], t[i]=b[i];
	}
	if (t[n]!=b[n])
	{
		puts("-1");
		return 0;
	}
	printf("%d\n", m);
	for (int i=1; i<n; i++)
	{
		while (a[i]<b[i]) increase(i);
		while (a[i]>b[i]) decrease(i);
	}
	return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
typedef long long ll;
const int MAXN=110000;
int cnt=100000;
char a[MAXN], b[MAXN];
int t[MAXN];
void decrease(int);
void increase(int p)
{
	if (a[p+1]=='9') decrease(p+1);
	a[p]++, a[p+1]++;
	if (cnt--) printf("%d 1\n", p);
	else exit(0);
}
void decrease(int p)
{
	if (a[p+1]=='0') increase(p+1);
	a[p]--, a[p+1]--;
	if (cnt--) printf("%d -1\n", p);
	else exit(0);
}
int main()
{
//	freopen("B.in", "r", stdin);
//	freopen("B.out", "w", stdout);
	int n; ll m=0;
	scanf("%d%s%s", &n, a+1, b+1);
	for (int i=1; i<=n; i++) t[i]=a[i];
	for (int i=1; i<n; i++)
	{
		m+=abs(t[i]-b[i]);
		t[i+1]+=b[i]-t[i], t[i]=b[i];
	}
	if (t[n]!=b[n])
	{
		puts("-1");
		return 0;
	}
	printf("%lld\n", m);
	for (int i=1; i<n; i++)
	{
		while (a[i]<b[i]) increase(i);
		while (a[i]>b[i]) decrease(i);
	}
	return 0;
}


#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cctype>

using namespace std;

const int MAXN=500005;

int n,k,m;
int a[MAXN],b[MAXN],cur[MAXN];
int pre[MAXN],res[MAXN];

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("code.in","r",stdin);
	//freopen("code.out","w",stdout);
	#endif
	int s,x;
	scanf("%d%d%d%d",&m,&k,&n,&s);
	for(int i=1;i<=m;i++)scanf("%d",&a[i]);
	for(int i=1;i<=s;i++)
	{
		scanf("%d",&x);
		++b[x];
	}
	int l=1,r,cnt=500000;
	for(int i=1;i<=500000;i++)
		if(!b[i])--cnt;
	for(int i=1;i<=m;i++)
	{
		++cur[a[i]];
		if(cur[a[i]]==b[a[i]])--cnt;
		for(;l<=i-k+1 && !cnt;++l)
		{
			if(cur[a[l]]==b[a[l]])++cnt;
			--cur[a[l]];
		}
		pre[i]=l-1;
	}
	l=r=0;
	for(int i=1;i<=m;i++)
		if(pre[i] && (pre[i]-1)/k+(m-i)/k+1>=n)
			{l=pre[i];r=i;break;}
	if(!r)return 0*printf("-1\n");
	memset(cur,0,sizeof(cur));
	int t=0;
	for(int i=l;i<=r;i++)
	{
		if(cur[a[i]]<b[a[i]])++cur[a[i]];
		else if(r-l+1-t>k)res[++t]=i;
	}
	for(int i=1;i<=(l-1)%k;i++)res[++t]=i;
	printf("%d\n",t);
	for(int i=1;i<=t;i++)
		printf("%d ",res[i]);
	return 0;
}


#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cctype>

using namespace std;

const int MAXN=100005;

int n;
char str1[MAXN],str2[MAXN];
int a[MAXN],b[MAXN];
int d[MAXN];

int cnt,resx[MAXN],rest[MAXN];
void print()
{
	printf("%d\n",cnt);
	for(int i=1;i<=cnt;i++)
		printf("%d %d\n",resx[i],rest[i]);
}
void work(int x,int t)
{
	a[x]+=t;a[x+1]+=t;
	resx[++cnt]=x;rest[cnt]=t;
	if(cnt==100000){print();exit(0);}
}

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("code.in","r",stdin);
	//freopen("code.out","w",stdout);
	#endif
	scanf("%d%s%s",&n,str1+1,str2+1);
	for(int i=1;i<=n;i++)
	{
		a[i]=str1[i]-'0',b[i]=str2[i]-'0';
		d[i]=b[i]-a[i]-d[i-1];
	}
	if(d[n])return 0*printf("-1\n");
	for(int i=1;i<n;i++)
	{
		while(a[i]<b[i])
		{
			if(a[i+1]<9)work(i,1);
			else
			{
				int pos=0,f=-1;
				for(int j=i+1;j<n;f=-f,j++)
				{
					if((f<0 && !a[j+1]) || (f>0 && a[j+1]==9))continue;
					pos=j;break;
				}
				for(int j=pos;j>=i;j--,f=-f)
					work(j,f);
			}
		}
		while(a[i]>b[i])
		{
			if(a[i+1]>0)work(i,-1);
			else
			{
				int pos=0,f=1;
				for(int j=i+1;j<n;f=-f,j++)
				{
					if((f<0 && !a[j+1]) || (f>0 && a[j+1]==9))continue;
					pos=j;break;
				}
				for(int j=pos;j>=i;j--,f=-f)
					work(j,f);
			}
		}
	}
	print();
	return 0;
}


#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cctype>

using namespace std;

typedef long long ll;
const int MAXN=100005;

int n;
ll c=0;
char str1[MAXN],str2[MAXN];
int a[MAXN],b[MAXN];
int d[MAXN];

int cnt,resx[MAXN],rest[MAXN];
void print()
{
	cout<<c<<endl;
	for(int i=1;i<=cnt;i++)
		printf("%d %d\n",resx[i],rest[i]);
}
void work(int x,int t)
{
	a[x]+=t;a[x+1]+=t;
	resx[++cnt]=x;rest[cnt]=t;
	if(cnt==100000){print();exit(0);}
}

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("code.in","r",stdin);
	//freopen("code.out","w",stdout);
	#endif
	scanf("%d%s%s",&n,str1+1,str2+1);
	for(int i=1;i<=n;i++)
	{
		a[i]=str1[i]-'0',b[i]=str2[i]-'0';
		d[i]=b[i]-a[i]-d[i-1];
		c+=abs(d[i]);
	}
	if(d[n])return 0*printf("-1\n");
	for(int i=1;i<n;i++)
	{
		while(a[i]<b[i])
		{
			if(a[i+1]<9)work(i,1);
			else
			{
				int pos=0,f=-1;
				for(int j=i+1;j<n;f=-f,j++)
				{
					if((f<0 && !a[j+1]) || (f>0 && a[j+1]==9))continue;
					pos=j;break;
				}
				for(int j=pos;j>=i;j--,f=-f)
					work(j,f);
			}
		}
		while(a[i]>b[i])
		{
			if(a[i+1]>0)work(i,-1);
			else
			{
				int pos=0,f=1;
				for(int j=i+1;j<n;f=-f,j++)
				{
					if((f<0 && !a[j+1]) || (f>0 && a[j+1]==9))continue;
					pos=j;break;
				}
				for(int j=pos;j>=i;j--,f=-f)
					work(j,f);
			}
		}
	}
	print();
	return 0;
}


#pragma comment(linker, "/stack:20000000000")
#define _CRT_SECURE_NO_DEPRECATE
#include <iostream>
#include <fstream>
#include <cstdio>
#include <stdio.h>
#include <cstdlib>
#include <stdlib.h>
#include <string>
#include <list>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <set>
// #include <unordered_set>
#include <stack>
#include <sstream>
#include <assert.h>
// #include <unordered_map>
#include <functional>
#include <climits>
#include <cstring>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
//typedef uint64_t ull;
//typedef std::pair<long double,long double> pdd;
#define fori(N)          for(int i = 0; i<(N); i++)
#define forj(N)         for(int j = 0; j<(N); j++)
#define fork(N)         for(int k = 0; k<(N); k++)
#define forl(N)         for(int l = 0; l<(N); l++)
#define ford(N)         for(int d = 0; d<(N); d++)
#define fori1(N)          for(int i = 1; i<=(N); i++)
#define forj1(N)         for(int j = 1; j<=(N); j++)
#define fork1(N)         for(int k = 1; k<=(N); k++)
#define ford1(N)         for(int d = 1; d<=(N); d++)
#define PI (2*asin(1))
#define read(n) scanf("%d", &n);
#define read2(n, m) scanf("%d%d", &n, &m);
#define readll(n) scanf("%I64d", &n);
#define mp make_pair

void redirectIO() {
	ios::sync_with_stdio(false); cin.tie(0);
#if defined(_DEBUG) || defined(_RELEASE)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
vector<int>a, b;
vector<pii>ans;
ll moves[110000];
int n;
int sgn(int a) {
	if (a > 0)return 1;
	else return -1;
}
bool canDo(int pos, int amount) {
	if (moves[pos] == 0)return false;
	if (a[pos] + amount < 0 || a[pos] + amount > 9)return false;
	if (a[pos + 1] + amount < 0 || a[pos + 1] + amount > 9)return false;
	if (pos == 0 && a[pos] + amount == 0)return false;
	if (moves[pos] == 0)return false;
	return true;
}
pii canTry(int pos) {
	if (pos < 0 || pos >= n - 1)return pii(-1, -1);
	int tr = sgn(moves[pos]);
	if(moves[pos]==0)return pii(-1, -1);
	if (canDo(pos, tr)) {
		return mp(pos, tr);
	}
	return pii(-1, -1);
}
int main()
{
	redirectIO();
	cin >> n;
	fori(n) {
		char c; cin >> c;
		a.push_back(c - '0');
	}
	fori(n) {
		char c; cin >> c;
		b.push_back(c - '0');
	}
	ll firstDig = 0, secondDig = 0;
	ll totalMoves = 0;
	fori(n) {
		if (i % 2)secondDig += (b[i] - a[i]);
		else firstDig += (b[i] - a[i]);
		if (i % 2)moves[i] = secondDig - firstDig;
		else moves[i] = firstDig - secondDig;
		totalMoves += abs(moves[i]);
	}
	if (moves[n - 1]) {
		cout << -1 << endl;
		return 0;
	}
	cout << totalMoves << endl;
	vector<pii>possible;
	vector<pii>actual;
	fori(n - 1) {
		if (moves[i] != 0) {
			int tr = sgn(moves[i]);
			if (canDo(i, tr)) {
				possible.push_back(mp(i, tr));

			}
		}
	}
	while (!possible.empty() && actual.size() < 100000){
		pii cur = possible.back();
		possible.pop_back();
		if (canDo(cur.first, cur.second)) {
			moves[cur.first] -= cur.second;
			a[cur.first] += cur.second;
			a[cur.first + 1] += cur.second;
			actual.push_back(cur);
			pii p = canTry(cur.first+1);
			if (p != pii(-1, -1))possible.push_back(p);
			p = canTry(cur.first);
			if (p != pii(-1, -1))possible.push_back(p);
			p = canTry(cur.first-1);
			if (p != pii(-1, -1))possible.push_back(p);
		}
}
	for (pii x : actual) {
		cout << x.first + 1 << " " << x.second << "\n";
	}

	return 0;
}


#pragma comment(linker, "/stack:20000000000")
#define _CRT_SECURE_NO_DEPRECATE
#include <iostream>
#include <fstream>
#include <cstdio>
#include <stdio.h>
#include <cstdlib>
#include <stdlib.h>
#include <string>
#include <list>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <set>
// #include <unordered_set>
#include <stack>
#include <sstream>
#include <assert.h>
// #include <unordered_map>
#include <functional>
#include <climits>
#include <cstring>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
//typedef uint64_t ull;
//typedef std::pair<long double,long double> pdd;
#define fori(N)          for(int i = 0; i<(N); i++)
#define forj(N)         for(int j = 0; j<(N); j++)
#define fork(N)         for(int k = 0; k<(N); k++)
#define forl(N)         for(int l = 0; l<(N); l++)
#define ford(N)         for(int d = 0; d<(N); d++)
#define fori1(N)          for(int i = 1; i<=(N); i++)
#define forj1(N)         for(int j = 1; j<=(N); j++)
#define fork1(N)         for(int k = 1; k<=(N); k++)
#define ford1(N)         for(int d = 1; d<=(N); d++)
#define PI (2*asin(1))
#define read(n) scanf("%d", &n);
#define read2(n, m) scanf("%d%d", &n, &m);
#define readll(n) scanf("%I64d", &n);
#define mp make_pair

void redirectIO() {
	ios::sync_with_stdio(false); cin.tie(0);
#if defined(_DEBUG) || defined(_RELEASE)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
vector<int>a, b;
vector<pii>ans;
ll moves[110000];
int n;
int sgn(int a) {
	if (a > 0)return 1;
	else return -1;
}
bool canDo(int pos, int amount) {
	if (moves[pos] == 0)return false;
	if (a[pos] + amount < 0 || a[pos] + amount > 9)return false;
	if (a[pos + 1] + amount < 0 || a[pos + 1] + amount > 9)return false;
	if (pos == 0 && a[pos] + amount == 0)return false;
	if (moves[pos] == 0)return false;
	return true;
}
pii canTry(int pos) {
	if (pos < 0 || pos >= n - 1)return pii(-1, -1);
	int tr = sgn(moves[pos]);
	if(moves[pos]==0)return pii(-1, -1);
	if (canDo(pos, tr)) {
		return mp(pos, tr);
	}
	return pii(-1, -1);
}
int main()
{
	redirectIO();
	cin >> n;
	fori(n) {
		char c; cin >> c;
		a.push_back(c - '0');
	}
	fori(n) {
		char c; cin >> c;
		b.push_back(c - '0');
	}
	ll firstDig = 0, secondDig = 0;
	ll totalMoves = 0;
	fori(n) {
		if (i % 2)secondDig += (b[i] - a[i]);
		else firstDig += (b[i] - a[i]);
		if (i % 2)moves[i] = secondDig - firstDig;
		else moves[i] = firstDig - secondDig;
		totalMoves += abs(moves[i]);
	}
	if (moves[n - 1]) {
		cout << -1 << endl;
		return 0;
	}
	cout << totalMoves << endl;
	vector<pii>possible;
	vector<pii>actual;
	fori(n - 1) {
		if (moves[i] != 0) {
			int tr = sgn(moves[i]);
			if (canDo(i, tr)) {
				possible.push_back(mp(i, tr));

			}
		}
	}
	while (!possible.empty() && actual.size() < 100000){
		pii cur = possible.back();
		possible.pop_back();
		if (canDo(cur.first, cur.second)) {
			moves[cur.first] -= cur.second;
			a[cur.first] += cur.second;
			actual.push_back(cur);
			pii p = canTry(cur.first+1);
			if (p != pii(-1, -1))possible.push_back(p);
			p = canTry(cur.first);
			if (p != pii(-1, -1))possible.push_back(p);
			p = canTry(cur.first-1);
			if (p != pii(-1, -1))possible.push_back(p);
		}
}
	for (pii x : actual) {
		cout << x.first + 1 << " " << x.second << "\n";
	}

	return 0;
}


#pragma comment(linker, "/stack:20000000000")
#define _CRT_SECURE_NO_DEPRECATE
#include <iostream>
#include <fstream>
#include <cstdio>
#include <stdio.h>
#include <cstdlib>
#include <stdlib.h>
#include <string>
#include <list>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <set>
// #include <unordered_set>
#include <stack>
#include <sstream>
#include <assert.h>
// #include <unordered_map>
#include <functional>
#include <climits>
#include <cstring>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
//typedef uint64_t ull;
//typedef std::pair<long double,long double> pdd;
#define fori(N)          for(int i = 0; i<(N); i++)
#define forj(N)         for(int j = 0; j<(N); j++)
#define fork(N)         for(int k = 0; k<(N); k++)
#define forl(N)         for(int l = 0; l<(N); l++)
#define ford(N)         for(int d = 0; d<(N); d++)
#define fori1(N)          for(int i = 1; i<=(N); i++)
#define forj1(N)         for(int j = 1; j<=(N); j++)
#define fork1(N)         for(int k = 1; k<=(N); k++)
#define ford1(N)         for(int d = 1; d<=(N); d++)
#define PI (2*asin(1))
#define read(n) scanf("%d", &n);
#define read2(n, m) scanf("%d%d", &n, &m);
#define readll(n) scanf("%I64d", &n);
#define mp make_pair

void redirectIO() {
	ios::sync_with_stdio(false); cin.tie(0);
#if defined(_DEBUG) || defined(_RELEASE)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
vector<int>a, b;
vector<pii>ans;
ll moves[110000];
int n;
int sgn(int a) {
	if (a > 0)return 1;
	else return -1;
}
bool canDo(int pos, int amount) {
	if (a[pos] + amount < 0 || a[pos] + amount > 9)return false;
	if (a[pos + 1] + amount < 0 || a[pos + 1] + amount > 9)return false;
	if (pos == 0 && a[pos] + amount == 0)return false;
	if (moves[pos] == 0)return false;
	return true;
}
pii canTry(int pos) {
	if (pos < 0 || pos >= n - 1)return pii(-1, -1);
	int tr = sgn(moves[pos]);
	if(moves[pos]==0)return pii(-1, -1);
	if (canDo(pos, tr)) {
		return mp(pos, tr);
	}
	return pii(-1, -1);
}
int main()
{
	redirectIO();
	cin >> n;
	fori(n) {
		char c; cin >> c;
		a.push_back(c - '0');
	}
	fori(n) {
		char c; cin >> c;
		b.push_back(c - '0');
	}
	ll firstDig = 0, secondDig = 0;
	ll totalMoves = 0;
	fori(n) {
		if (i % 2)secondDig += (b[i] - a[i]);
		else firstDig += (b[i] - a[i]);
		if (i % 2)moves[i] = secondDig - firstDig;
		else moves[i] = firstDig - secondDig;
		totalMoves += abs(moves[i]);
	}
	if (moves[n - 1]) {
		cout << -1 << endl;
		return 0;
	}
	cout << totalMoves << endl;
	vector<pii>possible;
	vector<pii>actual;
	fori(n - 1) {
		if (moves[i] != 0) {
			int tr = sgn(moves[i]);
			if (canDo(i, tr)) {
				possible.push_back(mp(i, tr));

			}
		}
	}
	while (!possible.empty() && actual.size() < 100000){
		pii cur = possible.back();
		possible.pop_back();
		if (canDo(cur.first, cur.second)) {
			moves[cur.first] -= cur.second;
			a[cur.first] += cur.second;
			actual.push_back(cur);
			pii p = canTry(cur.first+1);
			if (p != pii(-1, -1))possible.push_back(p);
			p = canTry(cur.first);
			if (p != pii(-1, -1))possible.push_back(p);
			p = canTry(cur.first-1);
			if (p != pii(-1, -1))possible.push_back(p);
		}
}
	for (pii x : actual) {
		cout << x.first + 1 << " " << x.second << "\n";
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 50;
#define int long long

int n, c, res = 0;
int a[N], b[N], f[N];
char s[N];

void Dfs(int o, int v) {
  f[o] += v; f[o + 1] += v;
  if(f[o + 1] > 9) Dfs(o + 1, 9 - f[o + 1]);
  if(f[o + 1] < 0) Dfs(o + 1, - f[o + 1]);
  for(int i = 1; i <= abs(v); i++) {
    printf("%lld %lld\n", o, v > 0 ? 1 : -1);
    c++;
    if(c == 100000) exit(0);
  }
}

signed main() {
  scanf("%lld", &n);
  scanf("%s", s + 1);
  for(int i = 1; i <= n; i++) a[i] = s[i] - '0', f[i] = a[i];
  scanf("%s", s + 1);
  for(int i = 1; i <= n; i++) b[i] = s[i] - '0';
  for(int i = 1; i < n; i++) {
    int t = b[i] - a[i];
    a[i + 1] += t;
    a[i] += t;
    res += abs(t);
  }
  if(a[n] != b[n]) return puts("-1"), 0;
  printf("%lld\n", res);
  for(int i = 1; i < n; i++) Dfs(i, b[i] - f[i]);
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 50;
#define int long long

int n, c, res = 0;
int a[N], b[N], f[N];
char s[N];

void Dfs(int o, int v) {
  f[o] += v; f[o + 1] += v;
  if(f[o + 1] > 9) Dfs(o + 1, 9 - f[o + 1]);
  if(f[o + 1] < 0) Dfs(o + 1, - f[o + 1]);
  for(int i = 1; i <= abs(v); i++) {
    printf("%lld %lld\n", o, v > 0 ? 1 : -1ll);
    c++;
    if(c == 100000) exit(0);
  }
}

signed main() {
  scanf("%lld", &n);
  scanf("%s", s + 1);
  for(int i = 1; i <= n; i++) a[i] = s[i] - '0', f[i] = a[i];
  scanf("%s", s + 1);
  for(int i = 1; i <= n; i++) b[i] = s[i] - '0';
  for(int i = 1; i < n; i++) {
    int t = b[i] - a[i];
    a[i + 1] += t;
    a[i] += t;
    res += abs(t);
  }
  if(a[n] != b[n]) return puts("-1"), 0;
  printf("%lld\n", res);
  for(int i = 1; i < n; i++) Dfs(i, b[i] - f[i]);
  return 0;
}


#define _CRT_SECURE_NO_DEPRECATE
#include <stdio.h>
#include <string>
#include <map>
#include <iostream>
#include <functional>
#include <algorithm>
#include <set>
#include <memory>

using namespace std;

typedef long long i64;
typedef unsigned long long u64;
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define R(x) x.begin(),x.end()
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef pair<i64, i64> pll;
typedef vector<pll> vll;

int main()
{
    int n;
    cin >> n;
    string A, B;
    cin >> A >> B;
    vector<int> diff( n - 1 );
    i64 sum = 0;
    FOR( i, 0, n - 1 )
    {
        diff[i] = B[i] - A[i];
        if ( i ) diff[i] -= diff[i - 1];
        sum += abs( diff[i] );
    }
    if ( (int) A[n - 1] + diff[n - 2] != (int) B[n - 1] )
    {
        cout << -1;
        return 0;
    }
    cout << sum << "\n";
    set<int> ok;
    auto isok = [&]( int i )
    {
        if ( !diff[i] )
        {
            return false;
        }
        else if ( diff[i] > 0 )
        {
            return A[i] < '9' && A[i + 1] < '9';
        }
        else if ( diff[i] < 0 )
        {
            return A[i] > '0' && A[i + 1] > '0' && ( i > 0 || A[i] > '1' );
        }
    };
    auto check = [&]( int i )
    {
        if ( isok( i ) )
        {
            ok.insert( i );
        }
        else
        {
            ok.erase( i );
        }
    };
    FOR( i, 0, n - 1 )
    {
        check( i );
    }
    FOR( z, 0, 100000 )
    {
        if ( ok.empty() )
        {
            break;
        }
        int i = *ok.begin();
        int v = diff[i] > 0 ? 1 : -1;
        cout << i + 1 << " " << v << "\n";
        A[i] += v;
        A[i + 1] += v;
        diff[i] -= v;
        if ( i ) check( i - 1 );
        check( i );
        if ( i < n - 2 ) check( i + 1 );
    }
    return 0;
}


#define _CRT_SECURE_NO_DEPRECATE
#include <stdio.h>
#include <string>
#include <map>
#include <iostream>
#include <functional>
#include <algorithm>
#include <set>
#include <memory>

using namespace std;

typedef long long i64;
typedef unsigned long long u64;
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define R(x) x.begin(),x.end()
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef pair<i64, i64> pll;
typedef vector<pll> vll;

int main()
{
    int n;
    cin >> n;
    string A, B;
    cin >> A >> B;
    vector<int> diff( n - 1 );
    int sum = 0;
    FOR( i, 0, n - 1 )
    {
        diff[i] = B[i] - A[i];
        if ( i ) diff[i] -= diff[i - 1];
        sum += abs( diff[i] );
    }
    if ( (int) A[n - 1] + diff[n - 2] != (int) B[n - 1] )
    {
        cout << -1;
        return 0;
    }
    cout << sum << "\n";
    set<int> ok;
    auto isok = [&]( int i )
    {
        if ( !diff[i] )
        {
            return false;
        }
        else if ( diff[i] > 0 )
        {
            return A[i] < '9' && A[i + 1] < '9';
        }
        else if ( diff[i] < 0 )
        {
            return A[i] > '0' && A[i + 1] > 0 && ( i > 0 || A[i] > '1' );
        }
    };
    auto check = [&]( int i )
    {
        if ( isok( i ) )
        {
            ok.insert( i );
        }
        else
        {
            ok.erase( i );
        }
    };
    FOR( i, 0, n - 1 )
    {
        check( i );
    }
    FOR( z, 0, 100000 )
    {
        if ( ok.empty() )
        {
            break;
        }
        int i = *ok.begin();
        int v = diff[i] > 0 ? 1 : -1;
        cout << i + 1 << " " << v << "\n";
        A[i] += v;
        A[i + 1] += v;
        diff[i] -= v;
        if ( i ) check( i - 1 );
        check( i );
        if ( i < n - 2 ) check( i + 1 );
    }
    return 0;
}


#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 102000;
int n,a[N],b[N];char S[N];
vector<Pii>ans;ll res;
set<int>Set[2][10];
void Modify(int p, int x){
	Set[p&1][x].erase(p);Set[p&1][a[p]].insert(p);
	a[p]=x;
}
int main() {
	read(n);
	scanf("%s",S+1);rep(i,1,n)a[i]=S[i]-'0';
	scanf("%s",S+1);rep(i,1,n)b[i]=S[i]-'0';
	int tot=0;
	for(int i=1;i<=n;i+=2)tot+=a[i]-b[i];
	for(int i=2;i<=n;i+=2)tot-=a[i]-b[i];
	if(tot){puts("-1");return 0;}
	rep(i,0,1)rep(j,0,9)Set[i][j].insert(n+1);
	rep(i,1,n)rep(j,0,9)if(a[i]!=j)
		Set[i&1][j].insert(i);
	rep(i,1,n)while(a[i]!=b[i]){
		if(a[i]>b[i]){
			int p=min(*Set[i&1][9].upper_bound(i),*Set[(i&1)^1][0].upper_bound(i));
			res+=p-i;Modify(i,a[i]-1);Modify(p,(p-i&1)?a[p]-1:a[p]+1);
			if(SZ(ans)<1e5){
				per(j,p-1,i)ans.pb(Pii(j,j-i&1?1:-1));
			}
		}
		else{
			int p=min(*Set[i&1][0].upper_bound(i),*Set[(i&1)^1][9].upper_bound(i));
			res+=p-i;Modify(i,a[i]+1);Modify(p,(p-i&1)?a[p]+1:a[p]-1);
			if(SZ(ans)<1e5){
				per(j,p-1,i)ans.pb(Pii(j,j-i&1?-1:1));
			}
		}
	}

	if(res>1e5)ans.resize(1e5);
	printf("%lld\n",res);
	rep(i,0,SZ(ans)-1)
		printf("%d %d\n",ans[i].fi,ans[i].se);
	return 0;
}


#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 102000;
int n,a[N],b[N];char S[N];
vector<Pii>ans;ll res;
set<int>Set[2][10];
void Modify(int p, int x){
	Set[p&1][x].erase(p);Set[p&1][a[p]].insert(p);
	a[p]=x;
}
int main() {
	read(n);
	scanf("%s",S+1);rep(i,1,n)a[i]=S[i]-'0';
	scanf("%s",S+1);rep(i,1,n)b[i]=S[i]-'0';
	int tot=0;
	for(int i=1;i<=n;i+=2)tot+=a[i]-b[i];
	for(int i=2;i<=n;i+=2)tot-=a[i]-b[i];
	if(tot){puts("-1");return 0;}
	rep(i,0,1)rep(j,0,9)Set[i][j].insert(n+1);
	rep(i,1,n)rep(j,0,9)if(a[i]!=j)
		Set[i&1][j].insert(i);
	rep(i,1,n)while(a[i]!=b[i]){
		if(a[i]>b[i]){
			int p=min(*Set[i&1][9].upper_bound(i),*Set[(i&1)^1][1].upper_bound(i));
			res+=p-i;Modify(i,a[i]-1);Modify(p,(p-i&1)?a[p]-1:a[p]+1);
			if(SZ(ans)<1e5){
				per(j,p-1,i)ans.pb(Pii(j,j-i&1?1:-1));
			}
		}
		else{
			int p=min(*Set[i&1][1].upper_bound(i),*Set[(i&1)^1][9].upper_bound(i));
			res+=p-i;Modify(i,a[i]+1);Modify(p,(p-i&1)?a[p]+1:a[p]-1);
			if(SZ(ans)<1e5){
				per(j,p-1,i)ans.pb(Pii(j,j-i&1?-1:1));
			}
		}
	}

	if(res>1e5)ans.resize(1e5);
	printf("%lld\n",res);
	rep(i,0,SZ(ans)-1)
		printf("%d %d\n",ans[i].fi,ans[i].se);
	return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<string>
#define I int
#define ll long long
#define F(i,a,b) for(I i=a;i<=b;i++)
#define Fd(i,a,b) for(I i=a;i>=b;i--)
#define N 100005
using namespace std;
char C,s[N];
I n,a[N],b[N],c[N],tot,x,y,t;
ll ans=0;
inline void R(I &x){
	x=0;char C=getchar();
	while(!isdigit(C)) C=getchar();
	while(isdigit(C)) x=(x<<3)+(x<<1)+(C^48),C=getchar();
}
/*void dg(I x,I k){
	if(x==n||tot>=100000) return;
	if(a[x+1]+k>9||a[x+1]+k<0) dg(x+1,-k);
	if(tot>=100000) return;
	a[x+1]+=k;a[x]+=k;
	if(k){
		++tot;
		ans[tot][0]=x,ans[tot][1]=k;
	}
}*/
I main(){
//	freopen("Once in a casino.in","r",stdin);
//	freopen("Once in a casino.out","w",stdout);
	R(n);
	scanf("%s",s+1);
	F(i,1,n) a[i]=s[i]^48;
	scanf("%s",s+1);
	F(i,1,n) b[i]=s[i]^48;
	c[1]=b[1]-a[1];
	ans=c[1]>0?c[1]:-c[1];
	F(i,2,n){
		c[i]=b[i]-a[i]-c[i-1];
		ans+=c[i]>0?c[i]:-c[i];
	}
	if(c[n]){printf("-1\n");return 0;}
	printf("%lld\n",ans);
	ans=min(ans,100000ll);
	x=y=1;
	while(ans--){
		while(!c[x]) x++,y++;
		while(c[y]<0&&!a[y+1]||(c[y]>0&&a[y+1]==9)) y++;
		t=c[y]<0?-1:1;
		printf("%d %d\n",y,t);
		a[y]+=t,a[y+1]+=t;c[y]-=t;
		y=max(y-1,x);
	}
	return 0;
}


#include <cstdio>
#include <stdlib.h>
#include <algorithm>
using namespace std;
#define N 1000005

int n; char s[N]; char t[N]; int a[N];  int b[N]; int c[N]; int times;
void fail(){ printf("-1\n"); exit(0); }
void dfs(int pos,int w){
    if(b[pos+1]+w<0||b[pos+1]+w>9) dfs(pos+1,-w);
    b[pos]+=w; b[pos+1]+=w; printf("%d %d\n",pos,w);
    if(--times==0) exit(0);
}
int main(){
    scanf("%d",&n);
    scanf("%s",s+1); for(int i=1;i<=n;++i) b[i]=s[i]-'0';
    scanf("%s",t+1); for(int i=1;i<=n;++i) c[i]=t[i]-'0';
    for(int i=1;i<=n;++i){
        a[i]=(c[i]-b[i])-a[i-1];
        times+=abs(a[i]);
    }
    if(a[n]) fail();
    printf("%d\n",times);
    if(!times) return 0;
    times=min(times,100000);
    for(int i=1;i<n;++i){
        while(b[i]!=c[i])  dfs(i,b[i]<c[i]?1:-1);
    }
    return 0;
}


#include<bits/stdc++.h>
#define MAXN 100010
using namespace std;
typedef pair<int,int> par;
int n,tot;
long long ans,sum;
char s[MAXN],t[MAXN];
void print (int x,int opt)
{
	tot++;
	printf ("%d %d\n",x,opt);
	if (tot==100000) exit (0);
}
bool check (int i,int opt)
{
	if (i==n) return 0;
	if (opt==-1)
	{
		if (s[i+1]>'0') return s[i]--,s[i+1]--,print (i,-1),1;
		if (check (i+1,1)) return s[i]--,s[i+1]--,print (i,-1),1;
		return 0;
	}
	if (opt==1)
	{
		if (s[i+1]<'9') return s[i]++,s[i+1]++,print (i,1),1;
		if (check (i+1,-1)) return s[i]++,s[i+1]++,print (i,1),1;
		return 0;
	}
}
int main()
{
	scanf ("%d%s%s",&n,s+1,t+1);
	for (int i=1;i<n;i++)
	{
		int S=sum+s[i]-'a',T=t[i]-'a';
		ans+=abs (S-T),sum=T-S;
	}
	if (sum+s[n]-'a'!=t[n]-'a') return puts ("-1"),0;
	printf ("%lld\n",ans);
	for (int i=1;i<n;i++)
	{
		while (s[i]>t[i]) if (!check (i,-1)) return puts ("-1"),0;
		while (s[i]<t[i]) if (!check (i,1)) return puts ("-1"),0;
	}
	return 0;
}


#include<bits/stdc++.h>
#define ri register int
#define fi first
#define se second
using namespace std;
inline int read(){
	int ans=0;
	char ch=getchar();
	while(!isdigit(ch))ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch^48),ch=getchar();
	return ans;
}
typedef long long ll;
const int N=1e5+5;
char s[N];
int n,a[N],b[N],det[N];
ll ans=0;
int main(){
	n=read();
	scanf("%s",s+1);
	for(ri i=1;i<=n;++i)a[i]=s[i]^48;
	scanf("%s",s+1);
	for(ri i=1;i<=n;++i)b[i]=s[i]^48;
	det[1]=b[1]-a[1];
	for(ri i=2;i<=n;++i)det[i]=b[i]-det[i-1]-a[i];
	if(det[n])return puts("-1"),0;
	for(ri i=1;i<n;++i)ans+=det[i]>0?det[i]:-det[i];
	cout<<ans<<'\n';
	ans=min(ans,100000ll);
	int p=1,cur=1,tmp;
	while(ans--){
		while(!det[p])++p,++cur;
		while((det[cur]>0&&a[cur+1]==9)||(det[cur]<0&&a[cur+1]==0))++cur;
		tmp=det[cur]>0?1:-1;
		cout<<cur<<' '<<tmp<<'\n';
		a[cur]+=tmp,a[cur+1]+=tmp,det[cur]-=tmp;
		cur=max(cur-1,p);
	}
	return 0;
}


#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;
int N;
const int MAX_N=1e5;
char A[MAX_N+1],B[MAX_N+1],tmp[MAX_N+1];
int main(){
	scanf("%d %s %s",&N,A,B);
	int ans=0;
	REP(i,N)tmp[i]=A[i];
	REP(i,N-1){
		ans+=abs(B[i]-tmp[i]);
		int dif=B[i]-tmp[i];
		tmp[i]+=dif;
		tmp[i+1]+=dif;
	}
	if(tmp[N-1]==B[N-1]){
		printf("%d\n",ans);
		REP(i,N)tmp[i]=A[i];
		int c=min(ans,(int)1e5);
		REP(i,N-1){
			int sgn;
			while(tmp[i]!=B[i]){
				if(B[i]>tmp[i]){
					sgn=1;
				}else{
					sgn=-1;
				}
				int inx=i;
				while(tmp[inx+1]+sgn<'0' || tmp[inx+1]+sgn>'9'){
					inx++;
					sgn*=-1;
				}
				for(;inx>=i;inx--){
					printf("%d %d\n",inx+1,sgn);
					tmp[inx]+=sgn;
					tmp[inx+1]+=sgn;
					sgn*=-1;
					c--;
					if(c==0){
						return 0;
					}
				}
			}
		}
	}else{
		printf("-1\n");
	}
}


#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;
int N;
const int MAX_N=1e5;
char rwA[MAX_N+1],rwB[MAX_N+1];
int A[MAX_N],B[MAX_N],tmp[MAX_N];
int main(){
	scanf("%d %s %s",&N,rwA,rwB);
	REP(i,N){
		A[i]=rwA[i]-'0';
		B[i]=rwB[i]-'0';
	}
	int ans=0;
	REP(i,N)tmp[i]=A[i];
	REP(i,N-1){
		int dif=B[i]-tmp[i];
		ans+=abs(dif);
		tmp[i]+=dif;
		tmp[i+1]+=dif;
	}
	if(tmp[N-1]==B[N-1]){
		printf("%d\n",ans);
		REP(i,N)tmp[i]=A[i];
		int c=min(ans,(int)1e5);
		REP(i,N-1){
			int sgn;
			while(tmp[i]!=B[i]){
				if(B[i]>tmp[i]){
					sgn=1;
				}else{
					sgn=-1;
				}
				int inx=i;
				while(tmp[inx+1]+sgn<0 || tmp[inx+1]+sgn>9){
					inx++;
					sgn*=-1;
				}
				for(;inx>=i;inx--){
					printf("%d %d\n",inx+1,sgn);
					tmp[inx]+=sgn;
					tmp[inx+1]+=sgn;
					sgn*=-1;
					c--;
					if(c==0){
						return 0;
					}
				}
			}
		}
	}else{
		printf("-1\n");
	}
}


#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;
int N;
const int MAX_N=1e5;
char rwA[MAX_N+1],rwB[MAX_N+1];
int A[MAX_N],B[MAX_N],tmp[MAX_N];
int main(){
	scanf("%d %s %s",&N,rwA,rwB);
	REP(i,N){
		A[i]=rwA[i]-'0';
		B[i]=rwB[i]-'0';
	}
	ll ans=0;
	REP(i,N)tmp[i]=A[i];
	REP(i,N-1){
		int dif=B[i]-tmp[i];
		ans+=abs(dif);
		tmp[i]+=dif;
		tmp[i+1]+=dif;
	}
	if(tmp[N-1]==B[N-1]){
		printf("%I64d\n",ans);
		REP(i,N)tmp[i]=A[i];
		ll c=min(ans,(ll)1e5);
		REP(i,N-1){
			int sgn;
			while(tmp[i]!=B[i]){
				if(B[i]>tmp[i]){
					sgn=1;
				}else{
					sgn=-1;
				}
				int inx=i;
				while(tmp[inx+1]+sgn<0 || tmp[inx+1]+sgn>9){
					inx++;
					sgn*=-1;
				}
				for(;inx>=i;inx--){
					printf("%d %d\n",inx+1,sgn);
					tmp[inx]+=sgn;
					tmp[inx+1]+=sgn;
					sgn*=-1;
					c--;
					if(c==0){
						return 0;
					}
				}
			}
		}
	}else{
		printf("-1\n");
	}
}


#include <bits/stdc++.h>
#define mkp make_pair
#define pb push_back
#define clr(a,b) memset(a, b, sizeof(a))
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vii;

void compute(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(n==1){
        cout<<0<<"\n"<<s<<"\n";
        return;
    }
    char color[] = {'R', 'G', 'B'};
    bool ok[] = {false, false, false};
    int res = 0;
    for(int i=0; i<n-1; i++){
        if(s[i] == s[i+1]){
            if(i+2<n){
                if(s[i+2] == s[i+1]){
                    if(s[i+1] == 'R') s[i+1] = 'G';
                    else if(s[i+1] == 'G') s[i+1] = 'B';
                    else if(s[i+1] == 'B') s[i+1] = 'R';
                    ++i;
                    ++res;
                    continue;
                }
                else{
                if(s[i] == 'G') ok[0] = true, ok[2] = true;
                else if(s[i] == 'R') ok[1] = true, ok[2] = true;
                else if(s[i] == 'B') ok[0] = true, ok[1] = true;
                if(s[i+2] == 'G') ok[1] = false;
                else if(s[i+2] == 'R') ok[0] = false;
                else if(s[i+2] == 'B') ok[2] = false;
                for(int j=0; j<3; j++){
                    if(ok[j]){
                        s[i+1] = color[j];
                        break;
                        }
                }
                }
            }
            else{
                if(s[i] == 'R') s[i+1] = 'G';
                if(s[i] == 'G') s[i+1] = 'B';
                if(s[i] == 'B') s[i+1] = 'R';
            }
            ++res;
        }
    }
    cout<<res<<"\n"<<s<<"\n";
}

int main(){
    compute();
    return 0;
}


#include <bits/stdc++.h>
#define mkp make_pair
#define pb push_back
#define clr(a,b) memset(a, b, sizeof(a))
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vii;

void compute(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(n==1){
        cout<<0<<"\n";
        return;
    }
    char color[] = {'R', 'G', 'B'};
    bool ok[] = {false, false, false};
    int res = 0;
    for(int i=0; i<n-1; i++){
        if(s[i] == s[i+1]){
            if(i+2<n){
                if(s[i+2] == s[i+1]){
                    if(s[i+1] == 'R') s[i+1] = 'G';
                    else if(s[i+1] == 'G') s[i+1] = 'B';
                    else if(s[i+1] == 'B') s[i+1] = 'R';
                    ++i;
                    ++res;
                    continue;
                }
                else{
                if(s[i] == 'G') ok[0] = true, ok[2] = true;
                if(s[i] == 'R') ok[1] = true, ok[2] = true;
                if(s[i] == 'B') ok[0] = true, ok[1] = true;
                if(s[i+2] == 'G') ok[1] = false;
                if(s[i+2] == 'R') ok[0] = false;
                if(s[i+2] == 'B') ok[2] = false;
                for(int j=0; j<3; j++){
                    if(ok[j]){
                        s[i+1] = color[j];
                        break;
                        }
                }
                }
            }
            else{
                if(s[i] == 'R') s[i+1] = 'G';
                if(s[i] == 'G') s[i+1] = 'B';
                if(s[i] == 'B') s[i+1] = 'R';
            }
            ++res;
        }
    }
    cout<<res<<"\n"<<s<<"\n";
}

int main(){
    compute();
    return 0;
}


#include <bits/stdc++.h>
#define mkp make_pair
#define pb push_back
#define clr(a,b) memset(a, b, sizeof(a))
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vii;

void compute(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(n==1){
        cout<<0<<"\n"<<s<<"\n";
        return;
    }
    char color[] = {'R', 'G', 'B'};
    bool ok[] = {false, false, false};
    int res = 0;
    for(int i=0; i<n-1; i++){
        if(s[i] == s[i+1]){
            if(i+2<n){
                if(s[i+2] == s[i+1]){
                    if(s[i+1] == 'R') s[i+1] = 'G';
                    else if(s[i+1] == 'G') s[i+1] = 'B';
                    else if(s[i+1] == 'B') s[i+1] = 'R';
                    ++i;
                    ++res;
                    continue;
                }
                else{
                if(s[i] == 'G') ok[0] = true, ok[2] = true;
                if(s[i] == 'R') ok[1] = true, ok[2] = true;
                if(s[i] == 'B') ok[0] = true, ok[1] = true;
                if(s[i+2] == 'G') ok[1] = false;
                if(s[i+2] == 'R') ok[0] = false;
                if(s[i+2] == 'B') ok[2] = false;
                for(int j=0; j<3; j++){
                    if(ok[j]){
                        s[i+1] = color[j];
                        break;
                        }
                }
                }
            }
            else{
                if(s[i] == 'R') s[i+1] = 'G';
                if(s[i] == 'G') s[i+1] = 'B';
                if(s[i] == 'B') s[i+1] = 'R';
            }
            ++res;
        }
    }
    cout<<res<<"\n"<<s<<"\n";
}

int main(){
    compute();
    return 0;
}


#include <bits/stdc++.h>
#define mkp make_pair
#define pb push_back
#define clr(a,b) memset(a, b, sizeof(a))
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vii;

void compute(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(n==1){
        cout<<0<<"\n";
        return;
    }
    char color[] = {'R', 'G', 'B'};
    bool ok[] = {false, false, false};
    int res = 0;
    for(int i=0; i<n-1; i++){
        if(s[i] == s[i+1]){
            if(i+2<n){
                if(s[i+2] == s[i+1]){
                    if(s[i+1] == 'R') s[i+1] = 'G';
                    if(s[i+1] == 'G') s[i+1] = 'B';
                    if(s[i+1] == 'B') s[i+1] = 'R';
                }
                //else{
                if(s[i] == 'G') ok[0] = true, ok[2] = true;
                if(s[i] == 'R') ok[1] = true, ok[2] = true;
                if(s[i] == 'B') ok[0] = true, ok[1] = true;
                if(s[i+2] == 'G') ok[1] = false;
                if(s[i+2] == 'R') ok[0] = false;
                if(s[i+2] == 'B') ok[2] = false;
                for(int j=0; j<3; j++){
                    if(ok[j]){
                        s[i+1] = color[j];
                        break;
                        }
                }
                //}
            }
            else{
                if(s[i] == 'R') s[i+1] = 'G';
                if(s[i] == 'G') s[i+1] = 'B';
                if(s[i] == 'B') s[i+1] = 'R';
            }
            ++res;
        }
    }
    cout<<res<<"\n"<<s<<"\n";
}

int main(){
    compute();
    return 0;
}


#include <bits/stdc++.h>
#define mkp make_pair
#define pb push_back
#define clr(a,b) memset(a, b, sizeof(a))
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vii;

void compute(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(n==1){
        cout<<0<<"\n"<<s<<"\n";
        return;
    }
    char color[] = {'R', 'G', 'B'};
    bool ok[] = {false, false, false};
    int res = 0;
    for(int i=0; i<n-1; i++){
        if(s[i] == s[i+1]){
            if(i+2<n){
                if(s[i+2] == s[i+1]){
                    if(s[i+1] == 'R') s[i+1] = 'G';
                    if(s[i+1] == 'G') s[i+1] = 'B';
                    if(s[i+1] == 'B') s[i+1] = 'R';
                }
                //else{
                if(s[i] == 'G') ok[0] = true, ok[2] = true;
                if(s[i] == 'R') ok[1] = true, ok[2] = true;
                if(s[i] == 'B') ok[0] = true, ok[1] = true;
                if(s[i+2] == 'G') ok[1] = false;
                if(s[i+2] == 'R') ok[0] = false;
                if(s[i+2] == 'B') ok[2] = false;
                for(int j=0; j<3; j++){
                    if(ok[j]){
                        s[i+1] = color[j];
                        break;
                        }
                }
                //}
            }
            else{
                if(s[i] == 'R') s[i+1] = 'G';
                if(s[i] == 'G') s[i+1] = 'B';
                if(s[i] == 'B') s[i+1] = 'R';
            }
            ++res;
        }
    }
    cout<<res<<"\n"<<s<<"\n";
}

int main(){
    compute();
    return 0;
}


#include <bits/stdc++.h>
#define mkp make_pair
#define pb push_back
#define clr(a,b) memset(a, b, sizeof(a))
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vii;

void compute(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(n==1){
        cout<<0<<"\n"<<s<<"\n";
        return;
    }
    char color[] = {'R', 'G', 'B'};
    bool ok[] = {false, false, false};
    int res = 0;
    for(int i=0; i<s.length()-1; i++){
        ok[0] = false, ok[1] = false, ok[2] = false;
        if(s[i] == s[i+1]){
            if(i+2<s.length()){
                if(s[i+2] == s[i+1]){
                    if(s[i+1] == 'R') s[i+1] = 'G';
                    else if(s[i+1] == 'G') s[i+1] = 'B';
                    else if(s[i+1] == 'B') s[i+1] = 'R';
                }
                else{
                if(s[i] == 'G') ok[0] = true, ok[2] = true;
                else if(s[i] == 'R') ok[1] = true, ok[2] = true;
                else if(s[i] == 'B') ok[0] = true, ok[1] = true;
                if(s[i+2] == 'G') ok[1] = false;
                else if(s[i+2] == 'R') ok[0] = false;
                else if(s[i+2] == 'B') ok[2] = false;
                for(int j=0; j<3; j++){
                    if(ok[j]){
                        s[i+1] = color[j];
                        break;
                        }
                }
                }
            }
            else{
                if(s[i] == 'R') s[i+1] = 'G';
                if(s[i] == 'G') s[i+1] = 'B';
                if(s[i] == 'B') s[i+1] = 'R';
            }
            ++i;
            ++res;
        }
    }
    cout<<res<<"\n"<<s<<"\n";
}

int main(){
    compute();
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int por(string x, string y)
{
    int ans=0;
    for(int i=0;i<x.length();i++)
    {
        if(x[i]!=y[i]) ans++;
    }
    return ans;
}

string kon(int n,string x, string y, string z)
{
    string ans="";
    for(int i=0;i<n;i++)
    {
        if(i%3==0) ans+=x;
        if(i%3==1) ans+=y;
        if(i%3==2) ans+=z;
    }
    return ans;
}
vector <int> dp(string s)
{
    int n=s.length();
    vector <int> x;
    for(int i=0;i<n-1;i++)
    {
        for(int j=i;j<n;j++)
        {
            if(s[i]!=s[j])
            {
                x.push_back(j);
                break;
            }
            if(j==n-1) x.push_back(0);
        }
    }
    return x;
}
string two(int n, string s)
{
    string ans="";
    vector <int> x=dp(s);
    ans+=s[0];
    for(int i=1;i<n-1;i++)
    {
        if(s[i]==ans[i-1])
        {
            if(x[i]==0)
            {
                if(ans[i-1]=='B') ans+='G';
                if(ans[i-1]=='R') ans+='G';
                if(ans[i-1]=='G') ans+='B';
            }
            else
            {
                if(s[i]=='B' && s[x[i]]=='G') ans+='R';
                if(s[i]=='B' && s[x[i]]=='R') ans+='G';
                if(s[i]=='G' && s[x[i]]=='B') ans+='R';
                if(s[i]=='G' && s[x[i]]=='R') ans+='B';
                if(s[i]=='R' && s[x[i]]=='B') ans+='G';
                if(s[i]=='R' && s[x[i]]=='G') ans+='B';
            }
        }
        else ans+=s[i];
    }
    if(s[n-1]==ans[n-2] && ans[n-2]=='B') ans+='G';
    if(s[n-1]==ans[n-2] && ans[n-2]=='R') ans+='G';
    if(s[n-1]==ans[n-2] && ans[n-2]=='G') ans+='B';
    if(s[n-1]!=ans[n-2]) ans+=s[n-1];
    return ans;
}

int main()
{
    ios_base::sync_with_stdio();cin.tie(0);
    int n;
    cin>>n;
    string s;
    cin>>s;
    string b=two(n,s);
    int ans=por(s,b);
    cout<<ans<<endl<<b;
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int por(string x, string y)
{
    int ans=0;
    for(int i=0;i<x.length();i++)
    {
        if(x[i]!=y[i]) ans++;
    }
    return ans;
}
vector <int> dp(string s)
{
    int n=s.length();
    vector <int> y;
    y.push_back(0);
    for(int i=n-2;i>=0;i--)
    {
        if(s[i]==s[i+1])
        {
            if(y[n-1-i-1]==0)
            {
                y.push_back(0);
            }
            if(y[n-1-i-1]!=0)
            {
                y.push_back(y[n-1-i-1]);
            }
        }
        else
        {
            y.push_back(i+1);
        }
    }
    vector <int> x;
    for(int i=n-1;i>=0;i--)
    {
        x.push_back(y[i]);
    }
    return x;
}
string two(int n, string s)
{
    string ans="";
    vector <int> x=dp(s);
    ans+=s[0];
    int k=0;
    for(int i=1;i<n-1;i++)
    {
        if(s[i]==ans[i-1])
        {
            if(x[i]==0)
            {
                if(ans[i-1]=='B') ans+='G';
                if(ans[i-1]=='R') ans+='G';
                if(ans[i-1]=='G') ans+='B';
            }
            else
            {
                if(s[i]=='B' && s[x[i]]=='G') ans+='R';
                if(s[i]=='B' && s[x[i]]=='R') ans+='G';
                if(s[i]=='G' && s[x[i]]=='B') ans+='R';
                if(s[i]=='G' && s[x[i]]=='R') ans+='B';
                if(s[i]=='R' && s[x[i]]=='B') ans+='G';
                if(s[i]=='R' && s[x[i]]=='G') ans+='B';
            }
        }
        else ans+=s[i];
    }
    if(s[n-1]==ans[n-2] && ans[n-2]=='B') ans+='G';
    if(s[n-1]==ans[n-2] && ans[n-2]=='R') ans+='G';
    if(s[n-1]==ans[n-2] && ans[n-2]=='G') ans+='B';
    if(s[n-1]!=ans[n-2]) ans+=s[n-1];
    return ans;
}

int main()
{
    ios_base::sync_with_stdio();cin.tie(0);
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(n==1)
    {
        cout<<0<<endl<<s;
        return 0;
    }
    if(n==2)
    {
        if(s[0]!=s[1])
        {
            cout<<0<<endl<<s;
            return 0;
        }
        else
        {
            cout<<1<<endl;
            if(s[0]=='B')
            {
                cout<<s[0]<<'G';
                return 0;
            }
            if(s[0]=='R')
            {
                cout<<s[0]<<'G';
                return 0;
            }
            if(s[0]=='G')
            {
                cout<<s[0]<<'B';
                return 0;
            }
        }
    }
    string b=two(n,s);
    int ans=por(s,b);
    cout<<ans<<endl<<b;
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int por(string x, string y)
{
    int ans=0;
    for(int i=0;i<x.length();i++)
    {
        if(x[i]!=y[i]) ans++;
    }
    return ans;
}

string kon(int n,string x, string y, string z)
{
    string ans="";
    for(int i=0;i<n;i++)
    {
        if(i%3==0) ans+=x;
        if(i%3==1) ans+=y;
        if(i%3==2) ans+=z;
    }
    return ans;
}
vector <int> dp(string s)
{
    int n=s.length();
    vector <int> x;
    for(int i=0;i<n-1;i++)
    {
        for(int j=i;j<n;j++)
        {
            if(s[i]!=s[j])
            {
                x.push_back(j);
                break;
            }
            if(j==n-1) x.push_back(0);
        }
    }
    return x;
}
string two(int n, string s)
{
    string ans="";
    vector <int> x=dp(s);
    ans+=s[0];
    for(int i=1;i<n-1;i++)
    {
        if(s[i]==ans[i-1])
        {
            if(x[i]==0)
            {
                if(ans[i-1]=='B') ans+='G';
                if(ans[i-1]=='R') ans+='G';
                if(ans[i-1]=='G') ans+='B';
            }
            else
            {
                if(s[i]=='B' && s[x[i]]=='G') ans+='R';
                if(s[i]=='B' && s[x[i]]=='R') ans+='G';
                if(s[i]=='G' && s[x[i]]=='B') ans+='R';
                if(s[i]=='G' && s[x[i]]=='R') ans+='B';
                if(s[i]=='R' && s[x[i]]=='B') ans+='G';
                if(s[i]=='R' && s[x[i]]=='G') ans+='B';
            }
        }
        else ans+=s[i];
    }
    if(s[n-1]==ans[n-2] && ans[n-2]=='B') ans+='G';
    if(s[n-1]==ans[n-2] && ans[n-2]=='R') ans+='G';
    if(s[n-1]==ans[n-2] && ans[n-2]=='G') ans+='B';
    if(s[n-1]!=ans[n-2]) ans+=s[n-1];
    return ans;
}

int main()
{
    ios_base::sync_with_stdio();cin.tie(0);
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(n==1)
    {
        cout<<0<<endl<<s;
        return 0;
    }
    if(n==2)
    {
        if(s[0]!=s[1])
        {
            cout<<0<<endl<<s;
            return 0;
        }
        else
        {
            cout<<1<<endl;
            if(s[0]=='B')
            {
                cout<<s[0]<<'G';
                return 0;
            }
            if(s[0]=='R')
            {
                cout<<s[0]<<'G';
                return 0;
            }
            if(s[0]=='G')
            {
                cout<<s[0]<<'B';
                return 0;
            }
        }
    }
    string b=two(n,s);
    int ans=por(s,b);
    cout<<ans<<endl<<b;
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int por(string x, string y)
{
    int ans=0;
    for(int i=0;i<x.length();i++)
    {
        if(x[i]!=y[i]) ans++;
    }
    return ans;
}

string kon(int n,string x, string y, string z)
{
    string ans="";
    for(int i=0;i<n;i++)
    {
        if(i%3==0) ans+=x;
        if(i%3==1) ans+=y;
        if(i%3==2) ans+=z;
    }
    return ans;
}

int main()
{
    ios_base::sync_with_stdio();cin.tie(0);
    int n;
    cin>>n;
    string s;
    cin>>s;
    string w[6];
     w[0]=kon(n,"B","G","R");
     w[1]=kon(n,"B","R","G");
     w[2]=kon(n,"G","B","R");
     w[3]=kon(n,"G","R","B");
     w[4]=kon(n,"R","B","G");
     w[5]=kon(n,"R","G","B");
     int ans[6];
     ans[0]=por(w[0],s);
     ans[1]=por(w[1],s);
     ans[2]=por(w[2],s);
     ans[3]=por(w[3],s);
     ans[4]=por(w[4],s);
     ans[5]=por(w[5],s);
    int odp=ans[0];
    for(int i=0;i<6;i++)
    {
        if(odp>ans[i]) odp=ans[i];
    }
    for(int i=0;i<6;i++)
    {
        if(odp==ans[i])
        {
            cout<<ans[i]<<endl;
            cout<<w[i];
            return 0;
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
#define init(c) memset(c,0,sizeof c)
#define S second
#define F first
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=20000005;
int n,k,x,t,a,b,m;
string s;
vi v;
int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r" , stdin);
	#endif // ONLINE_JUDGE
	cin >> n;
	cin >> s;
	int ans=0;
	if(n==2){
		if(s[0]==s[1])ans++;
	}
	for(int i =1;i<n;i++){
		if(s[i]==s[i-1]){
			if(s[i-1] == 'R' && s[i+1] == 'G'&&s[i]!='B'){
				s[i] = 'B';

			}else if(s[i-1] == 'R' && s[i+1] == 'B'&&s[i]!='G'){
				s[i] = 'G';
			}else if(s[i-1] == 'G' && s[i+1] == 'R'&&s[i]!='B'){
				s[i] = 'B';
			}else if(s[i-1] == 'G' && s[i+1] == 'B'&&s[i]!='R'){
				s[i] = 'R';
			}else if(s[i-1] == 'B' && s[i+1] == 'R'&&s[i]!='G'){
				s[i] = 'G';
			}else if(s[i-1] == 'B' && s[i+1] == 'G'&&s[i]!='R'){
				s[i] = 'R';
			}else if(s[i-1]==s[i+1]&&s[i]==s[i-1]){
				if(s[i] == 'B'){
					s[i]='R';
				}else if(s[i] == 'R'){
					s[i]='B';
				}else{
					s[i] ='B';
				}
			}
			ans++;
		}
	}
	cout << ans<<endl;
	cout<<s;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
#define init(c) memset(c,0,sizeof c)
#define S second
#define F first
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=20000005;
int n,k,x,t,a,b,m;
string s;
vi v;
int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r" , stdin);
	#endif // ONLINE_JUDGE
	cin >> n;
	cin >> s;
	int ans=0;
	if(n==2){
		if(s[0]==s[1])ans++;
	}
	for(int i =1;i<n;i++){
		if(s[i]==s[i-1]){
			if(s[i-1]!='R' && s[i+1]!='R'){
				s[i] = 'R';
			}else if(s[i-1]!='G'&&s[i+1]!='G'){
				s[i] = 'G';
			}else if(s[i-1]!='B'&&s[i+1]!='B'){
				s[i] = 'B';
			}
			ans++;
		}
	}
	cout << ans<<endl;
	cout<<s;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
#define init(c) memset(c,0,sizeof c)
#define S second
#define F first
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=20000005;
int n,k,x,t,a,b,m;
string s;
vi v;
int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r" , stdin);
	#endif // ONLINE_JUDGE
	cin >> n;
	cin >> s;
	int ans=0;
	if(n==2){
		if(s[0]==s[1])ans++;
	}
	for(int i =1;i<n-1;i+=2){
		if(s[i-1] == 'R' && s[i+1] == 'G'&&s[i]!='B'){
			s[i] = 'B';
			ans++;

		}else if(s[i-1] == 'R' && s[i+1] == 'B'&&s[i]!='G'){
			s[i] = 'G';
			ans++;
		}else if(s[i-1] == 'G' && s[i+1] == 'R'&&s[i]!='B'){
			s[i] = 'B';
			ans++;
		}else if(s[i-1] == 'G' && s[i+1] == 'B'&&s[i]!='R'){
			s[i] = 'R';
			ans++;
		}else if(s[i-1] == 'B' && s[i+1] == 'R'&&s[i]!='G'){
			s[i] = 'G';
			ans++;
		}else if(s[i-1] == 'B' && s[i+1] == 'G'&&s[i]!='R'){
			s[i] = 'R';
			ans++;
		}else if(s[i-1]==s[i+1]&&s[i]==s[i-1]){
			if(s[i] == 'B'){
				s[i]='R';
			}else if(s[i] == 'R'){
				s[i]='B';
			}else{
				s[i] ='B';
			}
			ans++;
		}
	}
	cout << ans<<endl;
	cout<<s;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
#define init(c) memset(c,0,sizeof c)
#define S second
#define F first
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=20000005;
int n,k,x,t,a,b,m;
string s;
vi v;
int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r" , stdin);
	#endif // ONLINE_JUDGE
	cin >> n;
	cin >> s;
	int ans=0;
	if(n==2){
		if(s[0]==s[1])ans++;
	}
	for(int i =1;i<n;i++){
		if(s[i]==s[i-1]){

			if(i+1<n&&s[i-1] == 'R' && s[i+1] == 'G'&&s[i]!='B'){
				s[i] = 'B';

			}else if(i+1<n&&s[i-1] == 'R' && s[i+1] == 'B'&&s[i]!='G'){
				s[i] = 'G';
			}else if(i+1<n&&s[i-1] == 'G' && s[i+1] == 'R'&&s[i]!='B'){
				s[i] = 'B';
			}else if(i+1<n&&s[i-1] == 'G' && s[i+1] == 'B'&&s[i]!='R'){
				s[i] = 'R';
			}else if(i+1<n&&s[i-1] == 'B' && s[i+1] == 'R'&&s[i]!='G'){
				s[i] = 'G';
			}else if(i+1<n&&s[i-1] == 'B' && s[i+1] == 'G'&&s[i]!='R'){
				s[i] = 'R';
			}else if(s[i]==s[i-1]){
				if(s[i] == 'B'){
					s[i]='R';
				}else if(s[i] == 'R'){
					s[i]='B';
				}else{
					s[i] ='B';
				}
			}
			ans++;
		}
	}
	cout << ans<<endl;
	cout<<s;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
#define init(c) memset(c,0,sizeof c)
#define S second
#define F first
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=20000005;
int n,k,x,t,a,b,m;
string s;
vi v;
int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r" , stdin);
	#endif // ONLINE_JUDGE
	cin >> n;
	cin >> s;
	int ans=0;

	for(int i =1;i<n-1;i++){
		if(s[i]==s[i-1]){
			if(s[i-1]!='R' && s[i+1]!='R'){
				s[i] = 'R';
			}else if(s[i-1]!='G'&&s[i+1]!='G'){
				s[i] = 'G';
			}else if(s[i-1]!='B'&&s[i+1]!='B'){
				s[i] = 'B';
			}
			ans++;
		}
	}
	if(s[n-1]==s[n-2]){
		ans++;
		if(s[n-2] != 'R'){
			s[n-1] ='R';
		}else{
			s[n-1]='G';
		}
	}
	cout << ans<<endl;
	cout<<s;

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int num[1<<25];
int main(){
	int n=0;
	memset(num,0,sizeof(num));
	char q[3]={'R','G','B'};
	map<char,int> p;
	p['R']=0;
	p['G']=1;
	p['B']=2;

	scanf("%d",&n);
	string s;
	cin>>s;
	for(int i=0;i<n;i++){
		num[i]=p[s[i]];
	}
	int ans=0;
	for(int i=1;i<n;i++){
		bool st[3]={0};
		if(num[i]==num[i-1]){
			st[num[i-1]]=st[num[i+1]]=1;
			for(int j=0;j<3;j++){
				if(!st[j]){
					num[i]=j;
					ans++;
					break;
				}
			}
		}
	}
	printf("%d\n",ans);
	for(int i=0;i<n;i++){
		printf("%c",q[num[i]]);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int num[1<<30];
int main(){
	int n=0;
	memset(num,0,sizeof(num));
	char q[3]={'R','G','B'};
	map<char,int> p;
	p['R']=0;
	p['G']=1;
	p['B']=2;

	scanf("%d",&n);
	string s;
	cin>>s;
	for(int i=0;i<n;i++){
		num[i]=p[s[i]];
	}
	int ans=0;
	for(int i=1;i<n;i++){
		bool st[3]={0};
		if(num[i]==num[i-1]){
			st[num[i-1]]=st[num[i+1]]=1;
			for(int j=0;j<3;j++){
				if(!st[j]){
					num[i]=j;
					ans++;
					break;
				}
			}
		}
	}
	printf("%d\n",ans);
	for(int i=0;i<n;i++){
		printf("%c",q[num[i]]);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int num[100010];
int main(){
	int n=0;
	memset(num,0,sizeof(num));
	char q[3]={'R','G','B'};
	map<char,int> p;
	p['R']=0;
	p['G']=1;
	p['B']=2;

	scanf("%d",&n);
	string s;
	cin>>s;
	for(int i=0;i<n;i++){
		num[i]=p[s[i]];
	}
	int ans=0;
	for(int i=1;i<n;i++){
		bool st[3]={0};
		if(num[i]==num[i-1]){
			st[num[i-1]]=st[num[i+1]]=1;
			for(int j=0;j<3;j++){
				if(!st[j]){
					num[i]=j;
					ans++;
					break;
				}
			}
		}
	}
	printf("%d\n",ans);
	for(int i=0;i<n;i++){
		printf("%c",q[num[i]]);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int num[20010];
int main(){
	int n=0;
	memset(num,0,sizeof(num));
	char q[3]={'R','G','B'};
	map<char,int> p;
	p['R']=0;
	p['G']=1;
	p['B']=2;

	scanf("%d",&n);
	string s;
	cin>>s;
	for(int i=0;i<n;i++){
		num[i]=p[s[i]];
	}
	int ans=0;
	for(int i=1;i<n;i++){
		bool st[3]={0};
		if(num[i]==num[i-1]){
			st[num[i-1]]=st[num[i+1]]=1;
			for(int j=0;j<3;j++){
				if(!st[j]){
					num[i]=j;
					ans++;
					break;
				}
			}
		}
	}
	printf("%d\n",ans);
	for(int i=0;i<n;i++){
		printf("%c",q[num[i]]);
	}
	return 0;
}


#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define __FastIO                                                               \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);
#define D cout << "ok" << endl;
#define _(x) cout << #x << "->" << x;
#define _n cout<<endl;
#define __ cout<<" ";
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define FIN freopen("in", "r", stdin);
#define FOUT freopen("out", "w", stdout);
#define f first
#define s second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<db, db> pdd;
template <typename T> using ordered_set = tree<T, null_type, less<T>,
                            rb_tree_tag, tree_order_statistics_node_update>;

int main()
{
	__FastIO;
#ifndef ONLINE_JUDGE
	FIN FOUT
#endif
	int n;
	cin >> n;
	string str;
	cin >> str;
	int cnt = 0;
	for (int i = 0; i < n;)
	{
		if (i < n - 2)
		{
			//_(str[i]) _n
			if (str[i] == str[i + 1] && str[i + 1] == str[i + 2])
			{
				if (str[i] == 'B') str[i + 1] = 'R';
				if (str[i] == 'G') str[i + 1] = 'R';
				if (str[i] == 'R') str[i + 1] = 'B';
				i += 3;
				cnt++;
			}

			else if (str[i] == str[i + 1])
			{
				if (str[i] == 'B' || str[i] == 'G' && str[i + 2] == 'G' || str[i + 2] == 'B') str[i + 2] = 'R';
				if (str[i] == 'B' || str[i] == 'R' && str[i + 2] == 'R' || str[i + 2] == 'B') str[i + 2] = 'G';
				if (str[i] == 'R' || str[i] == 'G' && str[i + 2] == 'G' || str[i + 2] == 'R') str[i + 2] = 'B';
				i += 2;
				cnt++;
			}
			else i++;
		}
		else if (i < n - 1)
		{
			if (str[i] == str[i + 1])
			{
				if (str[i] == 'B') str[i + 1] = 'R';
				if (str[i] == 'G') str[i + 1] = 'R';
				if (str[i] == 'R') str[i + 1] = 'B';
				cnt++;
				i += 2;
			}
			else i++;
		}
		else
			i++;
	}
	cout << cnt << endl;
	cout << str << endl;
}


#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define __FastIO                                                               \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);
#define D cout << "ok" << endl;
#define _(x) cout << #x << "->" << x;
#define _n cout<<endl;
#define __ cout<<" ";
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define FIN freopen("in", "r", stdin);
#define FOUT freopen("out", "w", stdout);
#define f first
#define s second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<db, db> pdd;
template <typename T> using ordered_set = tree<T, null_type, less<T>,
                            rb_tree_tag, tree_order_statistics_node_update>;
const int sz = 2e5 + 3;
int n;
string str;
int dp[sz][5];
int f(int i, int c)
{
	int &ret = dp[i][c];
	if (ret != -1) return ret;
	if (i == 0) return 0;
	int x, y;
	if (c == 1) x = 2, y = 3;
	if (c == 2) x = 1, y = 3;
	if (c == 3) x = 1, y = 2;
	int xx = 0, yy = 0;
	if (str[i] - '0' != x) xx = 1;
	if (str[i] - '0' != y) yy = 1;
	ret = min(xx + f(i - 1, x), yy + f(i - 1, y));
	return ret;
}
int main()
{
	__FastIO;
#ifndef ONLINE_JUDGE
	FIN FOUT
#endif
	memset(dp, -1, sizeof dp);
	cin >> n >> str;
	str = "#" + str;
	for (int i = 1; i <= n; i++)
	{
		if (str[i] == 'R') str[i] = '1';
		if (str[i] == 'G') str[i] = '2';
		if (str[i] == 'B') str[i] = '3';
	}

	int mn = min(f(n, 1), min(f(n, 2), f(n, 3)));
	int s = -1;
	if (dp[n][1] == mn) s = 1;
	if (dp[n][2] == mn) s = 2;
	if (dp[n][3] == mn) s = 3;
	string ans = "";
	for (int i = n; i > 0; i--)
	{
		ans += char(s + '0');
		int ee = INT_MAX;
		int t = -1;
		for (int j = 1; j <= 3; j++)
		{
			if (dp[i - 1][j] != -1 && j != s)
			{
				if (dp[i][s] >= dp[i - 1][j]) {
					int x = dp[i][s] - dp[i - 1][j];
					if (x <= ee)
					{
						ee = x;
						t = j;
					}
				}
			}
		}
		s = t;

	}
	reverse(ans.begin(), ans.end());
	cout << mn << endl;
	for (int i = 0; i < n; i++)
	{
		if (ans[i] == '1') cout << "R";
		if (ans[i] == '2') cout << "G";
		if (ans[i] == '3') cout << "B";
	}
	cout << endl;
}


#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define __FastIO                                                               \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);
#define D cout << "ok" << endl;
#define _(x) cout << #x << "->" << x;
#define _n cout<<endl;
#define __ cout<<" ";
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define FIN freopen("in", "r", stdin);
#define FOUT freopen("out", "w", stdout);
#define f first
#define s second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<db, db> pdd;
template <typename T> using ordered_set = tree<T, null_type, less<T>,
                            rb_tree_tag, tree_order_statistics_node_update>;

int main()
{
	__FastIO;
#ifndef ONLINE_JUDGE
	FIN FOUT
#endif
	int n;
	cin >> n;
	string str;
	cin >> str;
	int cnt = 0;
	for (int i = 0; i < n;)
	{
		if (i < n - 2)
		{
			//_(str[i]) _n
			if (str[i] == str[i + 1] && str[i + 1] == str[i + 2])
			{
				if (str[i] == 'B') str[i + 1] = 'R';
				if (str[i] == 'G') str[i + 1] = 'R';
				if (str[i] == 'R') str[i + 1] = 'B';
				i +=2;
				cnt++;
			}

			else if (str[i] == str[i + 1])
			{
				if ((str[i] == 'B' || str[i] == 'G' ) && (str[i + 2] == 'G' || str[i + 2] == 'B')) str[i + 1] = 'R';
				if ((str[i] == 'B' || str[i] == 'R' ) && (str[i + 2] == 'R' || str[i + 2] == 'B')) str[i + 1] = 'G';
				if ((str[i] == 'R' || str[i] == 'G' ) && (str[i + 2] == 'G' || str[i + 2] == 'R')) str[i + 1] = 'B';
				i +=1;
				cnt++;
			}
			else i++;
		}
		else if (i < n - 1)
		{
			if (str[i] == str[i + 1])
			{
				if (str[i] == 'B') str[i + 1] = 'R';
				if (str[i] == 'G') str[i + 1] = 'R';
				if (str[i] == 'R') str[i + 1] = 'B';
				cnt++;
				i +=1;
			}
			else i++;
		}
		else
			i++;
	}
	cout << cnt << endl;
	cout << str << endl;
}


#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define __FastIO                                                               \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);
#define D cout << "ok" << endl;
#define _(x) cout << #x << "->" << x;
#define _n cout<<endl;
#define __ cout<<" ";
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define FIN freopen("in", "r", stdin);
#define FOUT freopen("out", "w", stdout);
#define f first
#define s second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<db, db> pdd;
template <typename T> using ordered_set = tree<T, null_type, less<T>,
                            rb_tree_tag, tree_order_statistics_node_update>;

int main()
{
	__FastIO;
#ifndef ONLINE_JUDGE
	FIN FOUT
#endif
	int n;
	cin >> n;
	string str;
	cin >> str;
	int cnt = 0;
	for (int i = 0; i < n;)
	{
		if (i < n - 2)
		{
			//_(str[i]) _n
			if (str[i] == str[i + 1] && str[i + 1] == str[i + 2])
			{
				if (str[i] == 'B') str[i + 1] = 'R';
				if (str[i] == 'G') str[i + 1] = 'R';
				if (str[i] == 'R') str[i + 1] = 'B';
				i += 3;
				cnt++;
			}

			else if (str[i] == str[i + 1])
			{
				if ((str[i] == 'B' || str[i] == 'G' ) && (str[i + 2] == 'G' || str[i + 2] == 'B')) str[i + 1] = 'R';
				if ((str[i] == 'B' || str[i] == 'R' ) && (str[i + 2] == 'R' || str[i + 2] == 'B')) str[i + 1] = 'G';
				if ((str[i] == 'R' || str[i] == 'G' ) && (str[i + 2] == 'G' || str[i + 2] == 'R')) str[i + 1] = 'B';
				i += 2;
				cnt++;
			}
			else i++;
		}
		else if (i < n - 1)
		{
			if (str[i] == str[i + 1])
			{
				if (str[i] == 'B') str[i + 1] = 'R';
				if (str[i] == 'G') str[i + 1] = 'R';
				if (str[i] == 'R') str[i + 1] = 'B';
				cnt++;
				i += 2;
			}
			else i++;
		}
		else
			i++;
	}
	cout << cnt << endl;
	cout << str << endl;
}


#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define __FastIO                                                               \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);
#define D cout << "ok" << endl;
#define _(x) cout << #x << "->" << x;
#define _n cout<<endl;
#define __ cout<<" ";
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define FIN freopen("in", "r", stdin);
#define FOUT freopen("out", "w", stdout);
#define f first
#define s second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<db, db> pdd;
template <typename T> using ordered_set = tree<T, null_type, less<T>,
                            rb_tree_tag, tree_order_statistics_node_update>;

int main()
{
	__FastIO;
#ifndef ONLINE_JUDGE
	FIN FOUT
#endif
	int n;
	cin >> n;
	string str;
	cin >> str;
	int cnt = 0;
	for (int i = 0; i < n;)
	{
		if (i < n - 2)
		{
			//_(str[i]) _n
			if (str[i] == str[i + 1] && str[i + 1] == str[i + 2])
			{
				if (str[i] == 'B') str[i + 1] = 'R';
				if (str[i] == 'G') str[i + 1] = 'R';
				if (str[i] == 'R') str[i + 1] = 'B';
				i += 3;
				cnt++;
			}

			else if (str[i] == str[i + 1])
			{
				if (str[i] == 'B' && str[i + 2] == 'G') str[i + 1] = 'R';
				if (str[i] == 'B' && str[i + 2] == 'R') str[i + 1] = 'G';
				if (str[i] == 'R' && str[i + 2] == 'G') str[i + 1] = 'B';
				i += 2;
				cnt++;
			}
			else i++;
		}
		else if (i < n - 1)
		{
			if (str[i] == str[i + 1])
			{
				if (str[i] == 'B') str[i + 1] = 'R';
				if (str[i] == 'G') str[i + 1] = 'R';
				if (str[i] == 'R') str[i + 1] == 'B';
				cnt++;
				i += 2;
			}
			else i++;
		}
		else
			i++;
	}
	cout << cnt << endl;
	cout << str << endl;
}


#include<bits/stdc++.h>
using namespace std;
int ans, n;
string s;
char rgb[4]={'R','G','B'};
map<char, int> a;
int main(){
	//ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;cin>>s;
	a['R']=0;a['G']=1;a['B']=2;

	for(int i=1;i<n;i++){
		if(s[i]==s[i-1]){
			 ans++;
		if(s[i]!=s[i+1])
            s[i]=rgb[3-a[s[i+1]]-a[s[i-1]]];
        else
            s[i]=rgb[(a[s[i]]+1)%3];
		}
	}
	cout<<ans<<"\n";
	for (int i = 0; i < n;i++)
		cout << s[i];
		//system("pause");
		return 0;
}


#include<bits/stdc++.h>
using namespace std;
int ans, n;
string s;
char rgb[4]={'R','G','B'};
map<char, int> a;
int main(){
	//ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;cin>>s;
	a['R']=0;a['G']=1;a['B']=2;

	for(int i=1;i<n-1;i++){
		if(s[i]==s[i-1]){
			 ans++;
		if(s[i]!=s[i+1])
            s[i]=rgb[3-a[s[i+1]]-a[s[i-1]]];
        else
            s[i]=rgb[(a[s[i]]+1)%3];
		}
	}

	cout<<ans<<"\n";
	for (int i = 0; i < n;i++)
		cout << s[i];
		//system("pause");
		return 0;
}


#include<bits/stdc++.h>
using namespace std;
int ans, n;
string s;
char rgb[3]={'R','G','B'};
map<char, int> a;
int main(){
	//ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;cin>>s;
	a['R']=0;a['G']=1;a['B']=2;

	for(int i=1;i<n;i++){
		if(s[i]==s[i-1]){
			 ans++;
		if(s[i]!=s[i+1]){
                s[i]=rgb[3-a[s[i+1]]-a[s[i-1]]];
        }
        else
            s[i]=rgb[(a[s[i]]+1)%3];
		}
	}

	cout<<ans<<"\n";
	cout<<s;
	system("pause");
	return 0;
}