#include <iostream>
#include <map>
#include <ctime>
#include <vector>
#include <climits>
#include <algorithm>
#include <random>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#define inf 0x3f3f3f3f
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define rep(i, a, n) for(register int i = a; i <= n; ++ i)
#define per(i, a, n) for(register int i = n; i >= a; -- i)
//#define ONLINE_JUDGE
using namespace std;
typedef long long ll;
const int mod=1e9+7;
template<typename T>void write(T x)
{
    if(x<0)
    {
        putchar('-');
        x=-x;
    }
    if(x>9)
    {
        write(x/10);
    }
    putchar(x%10+'0');
}

template<typename T> void read(T &x)
{
    x = 0;char ch = getchar();ll f = 1;
    while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
    while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;};
ll ksm(ll a,ll n){//看是否要mod
	ll ans=1;
	while(n){
		if(n&1) ans=((ans%mod)*(a%mod))%mod;
		a=((a%mod)*(a%mod))%mod;
		n>>=1;
	}
	return ans%mod;
}
//==============================================================
#define int ll
const int maxn=105;
int mp[maxn][maxn],n,m,k;
ll dp[maxn][maxn][2][20];
int vis[maxn][maxn];
struct Edge{
    int dir,from,r;
    Edge(int d=0,int f=0,int rr=0){
        dir=d;
        from=f;
        r=rr;
    }
}path[maxn][maxn][2][20];
int dir[2][2]={-1,-1,-1,1};
void solve(int x,int y){
    if(vis[x][y]) return;
    vis[x][y]=1;
    dp[x][y][0][mp[x][y]%(k+1)]=dp[x][y][1][mp[x][y]%(k+1)]=mp[x][y];
    if(x==1) return ;
    for(int i=0;i<2;i++){
        int dx=x+dir[i][0],dy=y+dir[i][1];
        if(dx<=0||dy<=0||dx>n||dy>m) continue;
        solve(dx,dy);
        int tmp[20];rep(j,0,20-1) tmp[j]=dp[x][y][i][j];
        rep(j,0,k){
            if(max(dp[dx][dy][1][j],dp[dx][dy][0][j])==0) continue;
            rep(l,0,k){
                if(tmp[l]==0) continue;
                if(dp[x][y][i][(j+l)%(k+1)]<=max(dp[dx][dy][1][j],dp[dx][dy][0][j])+tmp[l]){
                    if(dp[dx][dy][1][j]+tmp[l]>=dp[x][y][i][(j+l)%(k+1)]){
                        path[x][y][i][(j+l)%(k+1)]=Edge(i,1,j);
                    }
                    else{
                        path[x][y][i][(j+l)%(k+1)]=Edge(i,0,j);
                    }
                }
                dp[x][y][i][(j+l)%(k+1)]=max(dp[x][y][i][(j+l)%(k+1)],max(dp[dx][dy][1][j],dp[dx][dy][0][j])+tmp[l]);
            }
        }
    }
}
char st[200],top=0;
void show_path(int sx,int sy,int sl,int sr){
    write(sy),putchar('\n');
    if(sl==1) st[++top]='R';
    else st[++top]='L';
    Edge tmp=path[sx][sy][sl][sr];
    sx+=dir[tmp.dir][0],sy+=dir[tmp.dir][1],sl=tmp.from,sr=(sr-tmp.r+(k+1))%(k+1);
    while(sx!=1){
        Edge now=path[sx][sy][sl][sr];
        sx=sx+dir[now.dir][0],sy=sy+dir[now.dir][1],sl=now.from,sr=(sr-now.r+(k+1))%(k+1);
        if(now.dir==1) st[++top]='R';
        else st[++top]='L';
    }
    rep(i,1,top){
        putchar(st[i]);
    }
}

signed main()
{
	#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	//===========================================================
    read(n),read(m),read(k);
    rep(i,1,n){
        rep(j,1,m){
            char t;cin>>t;
            mp[i][j]=t-'0';
        }
    }
    rep(i,1,m){
        solve(n,i);
    }
    ll res=0;
    int sx=0,sy=0,sl=0,sr=0;
    rep(i,1,m){
        if(res<=max(dp[n][i][0][0],dp[n][i][1][0])){
            if(dp[n][i][0][0]>=dp[n][i][1][0]){
                sx=n,sy=i,sl=0,sr=0;
            }
            else{
                sx=n,sy=i,sl=1,sr=0;
            }
        }
        res=max(res,max(dp[n][i][0][0],dp[n][i][1][0]));
    }
    /*rep(i,1,n){
        rep(j,1,m){
            rep(l,0,k){
                cerr<<dp[i][j][0][l]<<"|"<<dp[i][j][1][l]<<" ";
            }
            cerr<<"    ";
        }
        cerr<<endl;
    }
    Edge p=path[3][2][1][0];*/
    //cerr<<p.dir<<" "<<p.from<<" "<<p.r<<endl;
    if(res==0){
        puts("-1");
        return 0;
    }
    write(res),putchar('\n');
    show_path(sx,sy,sl,sr);
	//===========================================================
	return 0;
}


#include <iostream>
#include <map>
#include <ctime>
#include <vector>
#include <climits>
#include <algorithm>
#include <random>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#define inf 0x3f3f3f3f
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define rep(i, a, n) for(register int i = a; i <= n; ++ i)
#define per(i, a, n) for(register int i = n; i >= a; -- i)
#define ONLINE_JUDGE
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
template<typename T>void write(T x)
{
	if (x < 0)
	{
		putchar('-');
		x = -x;
	}
	if (x > 9)
	{
		write(x / 10);
	}
	putchar(x % 10 + '0');
}

template<typename T> void read(T& x)
{
	x = 0; char ch = getchar(); ll f = 1;
	while (!isdigit(ch)) { if (ch == '-')f *= -1; ch = getchar(); }
	while (isdigit(ch)) { x = x * 10 + ch - 48; ch = getchar(); }x *= f;
}
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; };
ll ksm(ll a, ll n) {//看是否要mod
	ll ans = 1;
	while (n) {
		if (n & 1) ans = ((ans % mod) * (a % mod)) % mod;
		a = ((a % mod) * (a % mod)) % mod;
		n >>= 1;
	}
	return ans % mod;
}
//==============================================================
#define int ll
const int maxn = 105;
ll dp[maxn][maxn][20];
int vis[maxn][maxn];
int mp[maxn][maxn];
pair<int, int> path[maxn][maxn][20];
int dir[2][2] = { -1,-1,-1,1 };
int n, m, k;

void solve(int x, int y) {
	if (vis[x][y]) return;
	vis[x][y] = 1;
	if (x == 1) {
		dp[x][y][(mp[x][y] % (k + 1))] = mp[x][y];
		return;
	}
	for (int i = 0; i <= 1; i++) {
		int dx = x + dir[i][0], dy = y + dir[i][1];
		if (dx <= 0 || dy <= 0 || dx > n || dy > m) continue;
		solve(dx, dy);
		rep(j, 0, k) {
			if (dp[dx][dy][j] + mp[x][y] >= dp[x][y][(j + mp[x][y]) % (k + 1)]) {
				dp[x][y][(j + mp[x][y]) % (k + 1)] = dp[dx][dy][j] + mp[x][y];
				path[x][y][(j + mp[x][y]) % (k + 1)] = make_pair(i, j);
			}
		}
	}
}
void print_path(int sy, int r) {
	int sx = n;
	while (sx != 1) {
		if (path[sx][sy][r].first == 1) {
			r = path[sx][sy][r].second;
			sx--, sy++;
			putchar('R');
		}
		else {
			r = path[sx][sy][r].second;
			sx--, sy--;
			putchar('L');
		}
	}
}

signed main()
{
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	//===========================================================
	read(n), read(m), read(k);
	memset(dp, -inf, sizeof(dp));
	rep(i, 1, n) {
		rep(j, 1, m) {
			char t; cin >> t;
			mp[i][j] = t - '0';
		}
	}
	rep(i, 1, m) {
		solve(n, i);
	}
	ll res = -inf, p;
	rep(i, 1, m) {
		if (res <= dp[n][i][0]) {
			res = dp[n][i][0];
			p = i;
		}
	}
	/*rep(i, 1, n) {
		rep(j, 1, m) {
			rep(l, 0, k + 1) {
				cerr << (dp[i][j][l] <= 0 ? 0 : dp[i][j][l]) << "|";
			}
			cerr << "    ";
		}
		cerr << endl;
	}*/
	if (res == -inf) {
		puts("-1");
		return 0;
	}
	write(res), putchar('\n');
	write(p), putchar('\n');
	print_path(p, 0);
	//===========================================================
	return 0;
}


#include <iostream>
#include <map>
#include <ctime>
#include <vector>
#include <climits>
#include <algorithm>
#include <random>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#define inf 0x3f3f3f3f
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define rep(i, a, n) for(register int i = a; i <= n; ++ i)
#define per(i, a, n) for(register int i = n; i >= a; -- i)
//#define ONLINE_JUDGE
using namespace std;
typedef long long ll;
const int mod=1e9+7;
template<typename T>void write(T x)
{
    if(x<0)
    {
        putchar('-');
        x=-x;
    }
    if(x>9)
    {
        write(x/10);
    }
    putchar(x%10+'0');
}

template<typename T> void read(T &x)
{
    x = 0;char ch = getchar();ll f = 1;
    while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
    while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;};
ll ksm(ll a,ll n){//看是否要mod
	ll ans=1;
	while(n){
		if(n&1) ans=((ans%mod)*(a%mod))%mod;
		a=((a%mod)*(a%mod))%mod;
		n>>=1;
	}
	return ans%mod;
}
//==============================================================
#define int ll
const int maxn=105;
int mp[maxn][maxn],n,m,k;
ll dp[maxn][maxn][2][20];
int vis[maxn][maxn];
struct Edge{
    int dir,from,r;
    Edge(int d=0,int f=0,int rr=0){
        dir=d;
        from=f;
        r=rr;
    }
}path[maxn][maxn][2][20];
int dir[2][2]={-1,-1,-1,1};
void solve(int x,int y){
    if(vis[x][y]) return;
    vis[x][y]=1;
    dp[x][y][0][mp[x][y]%(k+1)]=dp[x][y][1][mp[x][y]%(k+1)]=mp[x][y];
    if(x==1) return ;
    for(int i=0;i<2;i++){
        int dx=x+dir[i][0],dy=y+dir[i][1];
        if(dx<=0||dy<=0||dx>n||dy>m) continue;
        solve(dx,dy);
        int tmp[20];rep(j,0,20-1) tmp[j]=dp[x][y][i][j];
        rep(j,0,k){
            if(max(dp[dx][dy][1][j],dp[dx][dy][0][j])==0) continue;
            rep(l,0,k){
                if(tmp[l]==0) continue;
                if(dp[x][y][i][(j+l)%(k+1)]<=max(dp[dx][dy][1][j],dp[dx][dy][0][j])+tmp[l]){
                    if(dp[dx][dy][1][j]+tmp[l]>=dp[x][y][i][(j+l)%(k+1)]){
                        path[x][y][i][(j+l)%(k+1)]=Edge(i,1,j);
                    }
                    else{
                        path[x][y][i][(j+l)%(k+1)]=Edge(i,0,j);
                    }
                }
                dp[x][y][i][(j+l)%(k+1)]=max(dp[x][y][i][(j+l)%(k+1)],max(dp[dx][dy][1][j],dp[dx][dy][0][j])+tmp[l]);
            }
        }
    }
}
char st[200],top=0;
void show_path(int sx,int sy,int sl,int sr){
    if(sl==1) st[++top]='R';
    else st[++top]='L';
    Edge tmp=path[sx][sy][sl][sr];
    sx+=dir[tmp.dir][0],sy+=dir[tmp.dir][1],sl=tmp.from,sr=(sr-tmp.r+(k+1))%(k+1);
    while(sx!=1){
        Edge now=path[sx][sy][sl][sr];
        sx=sx+dir[now.dir][0],sy=sy+dir[now.dir][1],sl=now.from,sr=(sr-now.r+(k+1))%(k+1);
        if(now.dir==1) st[++top]='R';
        else st[++top]='L';
    }
    write(top),putchar('\n');
    rep(i,1,top){
        putchar(st[i]);
    }
}

signed main()
{
	#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	//===========================================================
    read(n),read(m),read(k);
    rep(i,1,n){
        rep(j,1,m){
            char t;cin>>t;
            mp[i][j]=t-'0';
        }
    }
    rep(i,1,m){
        solve(n,i);
    }
    ll res=0;
    int sx=0,sy=0,sl=0,sr=0;
    rep(i,1,m){
        if(res<=max(dp[n][i][0][0],dp[n][i][1][0])){
            if(dp[n][i][0][0]>=dp[n][i][1][0]){
                sx=n,sy=i,sl=0,sr=0;
            }
            else{
                sx=n,sy=i,sl=1,sr=0;
            }
        }
        res=max(res,max(dp[n][i][0][0],dp[n][i][1][0]));
    }
    /*rep(i,1,n){
        rep(j,1,m){
            rep(l,0,k){
                cerr<<dp[i][j][0][l]<<"|"<<dp[i][j][1][l]<<" ";
            }
            cerr<<"    ";
        }
        cerr<<endl;
    }
    Edge p=path[3][2][1][0];*/
    //cerr<<p.dir<<" "<<p.from<<" "<<p.r<<endl;
    if(res==0){
        puts("-1");
        return 0;
    }
    write(res),putchar('\n');
    show_path(sx,sy,sl,sr);
	//===========================================================
	return 0;
}


#include <iostream>
#include <map>
#include <ctime>
#include <vector>
#include <climits>
#include <algorithm>
#include <random>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#define inf 0x3f3f3f3f
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define rep(i, a, n) for(register int i = a; i <= n; ++ i)
#define per(i, a, n) for(register int i = n; i >= a; -- i)
//#define ONLINE_JUDGE
using namespace std;
typedef long long ll;
const int mod=1e9+7;
template<typename T>void write(T x)
{
    if(x<0)
    {
        putchar('-');
        x=-x;
    }
    if(x>9)
    {
        write(x/10);
    }
    putchar(x%10+'0');
}

template<typename T> void read(T &x)
{
    x = 0;char ch = getchar();ll f = 1;
    while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
    while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;};
ll ksm(ll a,ll n){//看是否要mod
	ll ans=1;
	while(n){
		if(n&1) ans=((ans%mod)*(a%mod))%mod;
		a=((a%mod)*(a%mod))%mod;
		n>>=1;
	}
	return ans%mod;
}
//==============================================================
#define int ll
const int maxn=105;
int mp[maxn][maxn],n,m,k;
ll dp[maxn][maxn][2][20];
int vis[maxn][maxn];
struct Edge{
    int dir,from,r;
    Edge(int d=0,int f=0,int rr=0){
        dir=d;
        from=f;
        r=rr;
    }
}path[maxn][maxn][2][20];
int dir[2][2]={-1,-1,-1,1};
void solve(int x,int y){
    if(vis[x][y]) return;
    vis[x][y]=1;
    dp[x][y][0][mp[x][y]%(k+1)]=dp[x][y][1][mp[x][y]%(k+1)]=mp[x][y];
    if(x==1) return ;
    for(int i=0;i<2;i++){
        int dx=x+dir[i][0],dy=y+dir[i][1];
        if(dx<=0||dy<=0||dx>n||dy>m) continue;
        solve(dx,dy);
        int tmp[20];rep(j,0,20-1) tmp[j]=dp[x][y][i][j];
        rep(j,0,k){
            if(max(dp[dx][dy][1][j],dp[dx][dy][0][j])==0) continue;
            rep(l,0,k){
                if(tmp[l]==0) continue;
                if(dp[x][y][i][(j+l)%(k+1)]<=max(dp[dx][dy][1][j],dp[dx][dy][0][j])+tmp[l]){
                    if(dp[dx][dy][1][j]+tmp[l]>=dp[x][y][i][(j+l)%(k+1)]){
                        path[x][y][i][(j+l)%(k+1)]=Edge(i,1,j);
                    }
                    else{
                        path[x][y][i][(j+l)%(k+1)]=Edge(i,0,j);
                    }
                }
                dp[x][y][i][(j+l)%(k+1)]=max(dp[x][y][i][(j+l)%(k+1)],max(dp[dx][dy][1][j],dp[dx][dy][0][j])+tmp[l]);
            }
        }
    }
}
char st[200],top=0;
void show_path(int sx,int sy,int sl,int sr){
    write(sy),putchar('\n');
    while(sx!=1){
        //cerr<<sx<<" "<<sy<<endl;
        Edge now=path[sx][sy][sl][sr];
        sx=sx+dir[now.dir][0],sy=sy+dir[now.dir][1],sl=now.from,sr=now.r;
        if(now.dir==1) st[++top]='R';
        else st[++top]='L';
    }
    //cerr<<sx<<" "<<sy<<endl;
    rep(i,1,top){
        putchar(st[i]);
    }
}

signed main()
{
	#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	//===========================================================
    read(n),read(m),read(k);
    rep(i,1,n){
        rep(j,1,m){
            char t;cin>>t;
            mp[i][j]=t-'0';
        }
    }
    rep(i,1,m){
        solve(n,i);
    }
    ll res=0;
    int sx=0,sy=0,sl=0,sr=0;
    rep(i,1,m){
        if(res<=max(dp[n][i][0][0],dp[n][i][1][0])){
            if(dp[n][i][0][0]>=dp[n][i][1][0]){
                sx=n,sy=i,sl=0,sr=0;
            }
            else{
                sx=n,sy=i,sl=1,sr=0;
            }
        }
        res=max(res,max(dp[n][i][0][0],dp[n][i][1][0]));
    }
    /*rep(i,1,n){
        rep(j,1,m){
            rep(l,0,k){
                cerr<<dp[i][j][0][l]<<"|"<<dp[i][j][1][l]<<" ";
            }
            cerr<<"    ";
        }
        cerr<<endl;
    }
    Edge p=path[3][2][1][0];*/
    //cerr<<p.dir<<" "<<p.from<<" "<<p.r<<endl;
    if(res==0){
        puts("-1");
        return 0;
    }
    write(res),putchar('\n');
    show_path(sx,sy,sl,sr);
	//===========================================================
	return 0;
}


#include <iostream>
#include <map>
#include <ctime>
#include <vector>
#include <climits>
#include <algorithm>
#include <random>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#define inf 0x3f3f3f3f
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define rep(i, a, n) for(register int i = a; i <= n; ++ i)
#define per(i, a, n) for(register int i = n; i >= a; -- i)
//#define ONLINE_JUDGE
using namespace std;
typedef long long ll;
const int mod=1e9+7;
template<typename T>void write(T x)
{
    if(x<0)
    {
        putchar('-');
        x=-x;
    }
    if(x>9)
    {
        write(x/10);
    }
    putchar(x%10+'0');
}

template<typename T> void read(T &x)
{
    x = 0;char ch = getchar();ll f = 1;
    while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
    while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;};
ll ksm(ll a,ll n){//看是否要mod
	ll ans=1;
	while(n){
		if(n&1) ans=((ans%mod)*(a%mod))%mod;
		a=((a%mod)*(a%mod))%mod;
		n>>=1;
	}
	return ans%mod;
}
//==============================================================
#define int ll
const int maxn=105;
int mp[maxn][maxn],n,m,k;
ll dp[maxn][maxn][2][20];
int vis[maxn][maxn];
struct Edge{
    int dir,from,r;
    Edge(int d=0,int f=0,int rr=0){
        dir=d;
        from=f;
        r=rr;
    }
}path[maxn][maxn][2][20];
int dir[2][2]={-1,-1,-1,1};
void solve(int x,int y){
    if(vis[x][y]) return;
    vis[x][y]=1;
    dp[x][y][0][mp[x][y]%(k+1)]=dp[x][y][1][mp[x][y]%(k+1)]=mp[x][y];
    if(x==1) return ;
    for(int i=0;i<2;i++){
        int dx=x+dir[i][0],dy=y+dir[i][1];
        if(dx<=0||dy<=0||dx>n||dy>m) continue;
        solve(dx,dy);
        int tmp[20];rep(j,0,20-1) tmp[j]=dp[x][y][i][j];
        rep(j,0,k){
            //if(max(dp[dx][dy][1][j],dp[dx][dy][0][j])==0) continue;
            rep(l,mp[x][y]%(k+1),k){
                //if(tmp[l]==0) continue;
                if(dp[x][y][i][(j+l)%(k+1)]<=max(dp[dx][dy][1][j],dp[dx][dy][0][j])+tmp[l]){
                    if(dp[dx][dy][1][j]+tmp[l]>=dp[x][y][i][(j+l)%(k+1)]){
                        path[x][y][i][(j+l)%(k+1)]=Edge(i,1,j);
                    }
                    else{
                        path[x][y][i][(j+l)%(k+1)]=Edge(i,0,j);
                    }
                }
                dp[x][y][i][(j+l)%(k+1)]=max(dp[x][y][i][(j+l)%(k+1)],max(dp[dx][dy][1][j],dp[dx][dy][0][j])+tmp[l]);
            }
        }
    }
}
char st[200],top=0;
void show_path(int sx,int sy,int sl,int sr){
    write(sy),putchar('\n');
    while(sx!=1){
        //cerr<<sx<<" "<<sy<<endl;
        Edge now=path[sx][sy][sl][sr];
        sr=now.r;
        if(max(dp[sx-1][sy-1][0][sr],dp[sx-1][sy-1][1][sr])>max(dp[sx-1][sy+1][0][sr],dp[sx-1][sy+1][1][sr])){
            sx=sx-1,sy=sy-1;
            st[++top]='L';
        }
        else{
            sx=sx-1,sy=sy+1;
            st[++top]='R';
        }
        /*if(now.dir==1) st[++top]='R';
        else st[++top]='L';*/
    }
    //cerr<<sx<<" "<<sy<<endl;
    rep(i,1,top){
        putchar(st[i]);
    }
}

signed main()
{
	#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	//===========================================================
    read(n),read(m),read(k);
    memset(dp,-inf,sizeof(dp));
    rep(i,1,n){
        rep(j,1,m){
            char t;cin>>t;
            mp[i][j]=t-'0';
        }
    }
    rep(i,1,m){
        solve(n,i);
    }
    ll res=0;
    int sx=0,sy=0,sl=0,sr=0;
    rep(i,1,m){
        if(res<=max(dp[n][i][0][0],dp[n][i][1][0])){
            if(dp[n][i][0][0]>=dp[n][i][1][0]){
                sx=n,sy=i,sl=0,sr=0;
            }
            else{
                sx=n,sy=i,sl=1,sr=0;
            }
        }
        res=max(res,max(dp[n][i][0][0],dp[n][i][1][0]));
    }
    /*rep(i,1,n){
        rep(j,1,m){
            rep(l,0,k){
                cerr<<dp[i][j][0][l]<<"|"<<dp[i][j][1][l]<<" ";
            }
            cerr<<"    ";
        }
        cerr<<endl;
    }
    Edge p=path[3][2][1][0];*/
    //cerr<<p.dir<<" "<<p.from<<" "<<p.r<<endl;
    if(res==0){
        puts("-1");
        return 0;
    }
    write(res),putchar('\n');
    show_path(sx,sy,sl,sr);
	//===========================================================
	return 0;
}


#include <iostream>
#include <map>
#include <ctime>
#include <vector>
#include <climits>
#include <algorithm>
#include <random>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#define inf 0x3f3f3f3f
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define rep(i, a, n) for(register int i = a; i <= n; ++ i)
#define per(i, a, n) for(register int i = n; i >= a; -- i)
//#define ONLINE_JUDGE
using namespace std;
typedef long long ll;
const int mod=1e9+7;
template<typename T>void write(T x)
{
    if(x<0)
    {
        putchar('-');
        x=-x;
    }
    if(x>9)
    {
        write(x/10);
    }
    putchar(x%10+'0');
}

template<typename T> void read(T &x)
{
    x = 0;char ch = getchar();ll f = 1;
    while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
    while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;};
ll ksm(ll a,ll n){//看是否要mod
	ll ans=1;
	while(n){
		if(n&1) ans=((ans%mod)*(a%mod))%mod;
		a=((a%mod)*(a%mod))%mod;
		n>>=1;
	}
	return ans%mod;
}
//==============================================================
#define int ll
const int maxn=105;
ll dp[maxn][maxn][20];
int vis[maxn][maxn];
int mp[maxn][maxn];
pair<int,int> path[maxn][maxn][20];
int dir[2][2]={-1,-1,-1,1};
int n,m,k;

void solve(int x,int y){
    if(vis[x][y]) return;
    vis[x][y]=1;
    if(x==1){
        dp[x][y][(mp[x][y]%(k+1))]=mp[x][y];
        return ;
    }
    for(int i=0;i<=1;i++){
        int dx=x+dir[i][0],dy=y+dir[i][1];
        if(dx<=0||dy<=0||dx>n||dy>m) continue;
        solve(dx,dy);
        rep(j,0,k){
            if(dp[dx][dy][j]+mp[x][y]>=dp[x][y][(j+mp[x][y])%(k+1)]){
                dp[x][y][(j+mp[x][y])%(k+1)]=dp[dx][dy][j]+mp[x][y];
                path[x][y][(j+mp[x][y])%(k+1)]=make_pair(i,j);
            }
        }
    }
}
void print_path(int sy,int r){
    int sx=n;
    while(sx!=1){
        if(path[sx][sy][r].first==1){
            r=path[sx][sy][r].second;
            sx--,sy++;
            putchar('R');
        }
        else{
            r=path[sx][sy][r].second;
            sx--,sy--;
            putchar('L');
        }
    }
}

signed main()
{
	#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	//===========================================================
	read(n),read(m),read(k);
    memset(dp,-inf,sizeof(dp));
    rep(i,1,n){
        rep(j,1,m){
            char t;cin>>t;
            mp[i][j]=t-'0';
        }
    }
    rep(i,1,n){
        solve(n,i);
    }
    ll res=-inf,p;
    rep(i,1,m){
        if(res<=dp[n][i][0]){
            res=dp[n][i][0];
            p=i;
        }
    }
    rep(i,1,n){
        rep(j,1,m){
            rep(l,0,k+1){
                cerr<<(dp[i][j][l]<=0?0:dp[i][j][l])<<"|";
            }
            cerr<<"    ";
        }
        cerr<<endl;
    }
    if(res==-inf){
        puts("-1");
        return 0;
    }
    write(res),putchar('\n');
    write(p),putchar('\n');
    print_path(p,0);
	//===========================================================
	return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cmath>
#include<iomanip>
#include<string.h>
#include<limits.h>
#include<queue>
#include<set>
#include<map>
#include<bits/stdc++.h>
using namespace std;
typedef long long int llt;
typedef pair<llt,llt> pll;
typedef pair<char,char> pcc;
typedef pair<string,string> pss;
typedef pair<llt,char> plc;
#define endl "\n"
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define tr(x) cout<<x<<endl;
#define tr2(x,y) cout<<x<<" "<<y<<endl;
#define tr3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
#define tr4(w,x,y,z) cout<<w<<" "<<x<<" "<<y<<" "<<z<<endl;
#define make0(a) memset(a,0,sizeof(a))
#define trv(v) for(llt i=0;i<v.size();i++) cout<<v[i]<<" "; cout<<endl;
bool cmp(plc p1,plc p2){
	return p1.first>p2.first;
}
llt n,m,k;
bool check(llt x,llt y){
	if(x<0 or y<0 or x>=n or y>=m)
		return false;
	return true;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
  cin>>n>>m>>k;
	k++;
	llt a[n][m],i,j,x;
	llt dp[n][m][k],ans[n][m][k][2];
	string s[n];
	llt zero[n];
	for(i=0;i<n;i++){
		cin>>s[i];
		zero[i]=-1;
	}
	for(i=0;i<n;i++)
		for(j=0;j<m;j++){
			a[n-i-1][j]=(int)(s[i][j])-48;
			if(a[n-i-1][j]==0)
				zero[n-i-1]=j;
		}
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			for(x=0;x<k;x++){
				dp[i][j][x]=0;
				ans[i][j][x][1]=-1;
			}
		}
	}
	for(i=0;i<m;i++){
		for(j=0;j<k;j++){
			if(j==a[0][i]%k)
				dp[0][i][j]=a[0][i];
			else
				dp[0][i][j]=0;
		}
	}
	for(i=1;i<n;i++){
		for(j=0;j<m;j++){
			if(check(i-1,j-1)==true){
				for(x=0;x<k;x++)
					if(dp[i][j][(dp[i-1][j-1][x]+a[i][j])%k]<=dp[i-1][j-1][x]+a[i][j]){
						dp[i][j][(dp[i-1][j-1][x]+a[i][j])%k]=max(dp[i][j][(dp[i-1][j-1][x]+a[i][j])%k],dp[i-1][j-1][x]+a[i][j]);
						ans[i][j][(dp[i-1][j-1][x]+a[i][j])%k][0]=i-1;
						ans[i][j][(dp[i-1][j-1][x]+a[i][j])%k][1]=j-1;
					}
			}
			if(check(i-1,j+1)==true){
				for(x=0;x<k;x++)
					if(dp[i][j][(dp[i-1][j+1][x]+a[i][j])%k]<=dp[i-1][j+1][x]+a[i][j]){
						dp[i][j][(dp[i-1][j+1][x]+a[i][j])%k]=max(dp[i][j][(dp[i-1][j+1][x]+a[i][j])%k],dp[i-1][j+1][x]+a[i][j]);
						ans[i][j][(dp[i-1][j+1][x]+a[i][j])%k][0]=i-1;
						ans[i][j][(dp[i-1][j+1][x]+a[i][j])%k][1]=j+1;
					}
			}
		}
	}
	vector<char> steps;
	x=0;
	llt index=-1;
	for(i=0;i<m;i++){
		if(dp[n-1][i][0]>x){
			x=dp[n-1][i][0];
			index=i;
		}
	}
	if(index==-1){
		bool c=false;
		for(i=0;i<n;i++){
			if(zero[i]==(-1)){
				c=true;
				break;
			}
		}
		if(c==false){
			cout<<"0"<<endl;
			cout<<zero[0]<<endl;
			for(i=0;i<n-1;i++){
				if(zero[i]=zero[i-1]+1){
					cout<<'L';
				}
				else
					cout<<'R';
			}
			return 0;
		}
		cout<<"-1";
		return 0;
	}
	llt sum=x;
	x=n-1;
	llt y=0,z;
	while(x>0){
		z=ans[x][index][y][1]+1;
		// tr4(x,index,y,z-1)
		if(ans[x][index][y][1]==index-1)
			steps.pb('R');
		else if(ans[x][index][y][1]==index+1)
			steps.pb('L');
		else{
			sum=-1;
			break;
		}
		llt temp=a[x][index];
		index=ans[x][index][y][1];
		x--;
		y=((y-temp)%k+k)%k;

	}
	if(sum==-1){
		cout<<sum;
		return 0;
	}
	cout<<sum<<endl<<z<<endl;
	for(i=steps.size()-1;i>=0;i--)
		cout<<steps[i];
	cout<<endl;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cmath>
#include<iomanip>
#include<string.h>
#include<limits.h>
#include<queue>
#include<set>
#include<map>
#include<bits/stdc++.h>
using namespace std;
typedef long long int llt;
typedef pair<llt,llt> pll;
typedef pair<char,char> pcc;
typedef pair<string,string> pss;
typedef pair<llt,char> plc;
#define endl "\n"
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define tr(x) cout<<x<<endl;
#define tr2(x,y) cout<<x<<" "<<y<<endl;
#define tr3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
#define tr4(w,x,y,z) cout<<w<<" "<<x<<" "<<y<<" "<<z<<endl;
#define make0(a) memset(a,0,sizeof(a))
#define trv(v) for(llt i=0;i<v.size();i++) cout<<v[i]<<" "; cout<<endl;
bool cmp(plc p1,plc p2){
	return p1.first>p2.first;
}
llt n,m,k;
bool check(llt x,llt y){
	if(x<0 or y<0 or x>=n or y>=m)
		return false;
	return true;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
  cin>>n>>m>>k;
	k++;
	llt a[n][m],i,j,x;
	llt dp[n][m][k],ans[n][m][k][2];
	string s[n];
	llt zero[n];
	for(i=0;i<n;i++){
		cin>>s[i];
		zero[i]=-1;
	}
	for(i=0;i<n;i++)
		for(j=0;j<m;j++){
			a[n-i-1][j]=(int)(s[i][j])-48;
			if(a[n-i-1][j]==0)
				zero[n-i-1]=j;
		}
	for(i=0;i<n;i++)
		for(j=0;j<m;j++)
			for(x=0;x<k;x++)
				dp[i][j][x]=0;
	for(i=0;i<m;i++){
		for(j=0;j<k;j++){
			if(j==a[0][i]%k)
				dp[0][i][j]=a[0][i];
			else
				dp[0][i][j]=0;
		}
	}
	for(i=1;i<n;i++){
		for(j=1;j<m;j++){
			if(check(i-1,j-1)==true){
				for(x=0;x<k;x++)
					if(dp[i][j][(dp[i-1][j-1][x]+a[i][j])%k]<dp[i-1][j-1][x]+a[i][j]){
						dp[i][j][(dp[i-1][j-1][x]+a[i][j])%k]=max(dp[i][j][(dp[i-1][j-1][x]+a[i][j])%k],dp[i-1][j-1][x]+a[i][j]);
						ans[i][j][(dp[i-1][j+1][x]+a[i][j])%k][0]=i-1;
						ans[i][j][(dp[i-1][j+1][x]+a[i][j])%k][1]=j-1;
					}
			}
			if(check(i-1,j+1)==true){
				for(x=0;x<k;x++)
					if(dp[i][j][(dp[i-1][j+1][x]+a[i][j])%k]<dp[i-1][j+1][x]+a[i][j]){
						dp[i][j][(dp[i-1][j+1][x]+a[i][j])%k]=max(dp[i][j][(dp[i-1][j+1][x]+a[i][j])%k],dp[i-1][j+1][x]+a[i][j]);
						ans[i][j][(dp[i-1][j+1][x]+a[i][j])%k][0]=i-1;
						ans[i][j][(dp[i-1][j+1][x]+a[i][j])%k][1]=j+1;
					}
			}
		}
	}
	vector<char> steps;
	x=0;
	llt index=-1;
	for(i=0;i<m;i++){
		if(dp[n-1][i][0]>x){
			x=dp[n-1][i][0];
			index=i;
		}
	}
	if(index==-1){
		bool c=false;
		for(i=0;i<n;i++){
			if(zero[i]==(-1)){
				c=true;
				break;
			}
		}
		if(c==false){
			cout<<"0"<<endl;
			cout<<zero[0]<<endl;
			for(i=0;i<n-1;i++){
				if(zero[i]=zero[i-1]+1){
					cout<<'L';
				}
				else
					cout<<'R';
			}
			return 0;
		}
		cout<<"-1";
		return 0;
	}
	cout<<x<<endl;
	// cout<<index<<endl;
	x=n-1;
	llt y=0,z;
	while(x>0){
		z=ans[x][index][y][1]+1;
		// cout<<x<<" "<<index<<" "<<z<<endl;
		if(ans[x][index][y][1]==index-1)
			steps.pb('R');
		else
			steps.pb('L');
		llt temp=a[x][index];
		index=ans[x][index][y][1];
		x--;
		y=(y-temp)%k;

	}
	cout<<z<<endl;
	for(i=steps.size()-1;i>=0;i--)
		cout<<steps[i];
	cout<<endl;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cmath>
#include<iomanip>
#include<string.h>
#include<limits.h>
#include<queue>
#include<set>
#include<map>
#include<bits/stdc++.h>
using namespace std;
typedef long long int llt;
typedef pair<llt,llt> pll;
typedef pair<char,char> pcc;
typedef pair<string,string> pss;
typedef pair<llt,char> plc;
#define endl "\n"
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define tr(x) cout<<x<<endl;
#define tr2(x,y) cout<<x<<" "<<y<<endl;
#define tr3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
#define tr4(w,x,y,z) cout<<w<<" "<<x<<" "<<y<<" "<<z<<endl;
#define make0(a) memset(a,0,sizeof(a))
#define trv(v) for(llt i=0;i<v.size();i++) cout<<v[i]<<" "; cout<<endl;
bool cmp(plc p1,plc p2){
	return p1.first>p2.first;
}
llt n,m,k;
bool check(llt x,llt y){
	if(x<0 or y<0 or x>=n or y>=m)
		return false;
	return true;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
  cin>>n>>m>>k;
	k++;
	llt a[n][m],i,j,x;
	llt dp[n][m][k],ans[n][m][k][2];
	string s[n];
	llt zero[n];
	for(i=0;i<n;i++){
		cin>>s[i];
		zero[i]=-1;
	}
	for(i=0;i<n;i++)
		for(j=0;j<m;j++){
			a[n-i-1][j]=(int)(s[i][j])-48;
			if(a[n-i-1][j]==0)
				zero[n-i-1]=j;
		}
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			for(x=0;x<k;x++){
				dp[i][j][x]=0;
				ans[i][j][x][1]=-1;
			}
		}
	}
	for(i=0;i<m;i++){
		for(j=0;j<k;j++){
			if(j==a[0][i]%k)
				dp[0][i][j]=a[0][i];
			else
				dp[0][i][j]=0;
		}
	}
	for(i=1;i<n;i++){
		for(j=0;j<m;j++){
			if(check(i-1,j-1)==true){
				for(x=0;x<k;x++)
					if(dp[i][j][(dp[i-1][j-1][x]+a[i][j])%k]<=dp[i-1][j-1][x]+a[i][j]){
						dp[i][j][(dp[i-1][j-1][x]+a[i][j])%k]=max(dp[i][j][(dp[i-1][j-1][x]+a[i][j])%k],dp[i-1][j-1][x]+a[i][j]);
						ans[i][j][(dp[i-1][j-1][x]+a[i][j])%k][0]=i-1;
						ans[i][j][(dp[i-1][j-1][x]+a[i][j])%k][1]=j-1;
					}
			}
			if(check(i-1,j+1)==true){
				for(x=0;x<k;x++)
					if(dp[i][j][(dp[i-1][j+1][x]+a[i][j])%k]<=dp[i-1][j+1][x]+a[i][j]){
						dp[i][j][(dp[i-1][j+1][x]+a[i][j])%k]=max(dp[i][j][(dp[i-1][j+1][x]+a[i][j])%k],dp[i-1][j+1][x]+a[i][j]);
						ans[i][j][(dp[i-1][j+1][x]+a[i][j])%k][0]=i-1;
						ans[i][j][(dp[i-1][j+1][x]+a[i][j])%k][1]=j+1;
					}
			}
		}
	}
	vector<char> steps;
	x=0;
	llt index=-1;
	for(i=0;i<m;i++){
		if(dp[n-1][i][0]>=x){
			x=dp[n-1][i][0];
			index=i;
		}
	}
	llt sum=x;
	x=n-1;
	llt y=0,z;
	if(index==-1){
		cout<<"-1";
		return 0;
	}
	while(x>0){
		z=ans[x][index][y][1]+1;
		// tr4(x,index,y,z-1)
		if(ans[x][index][y][1]==index-1)
			steps.pb('R');
		else if(ans[x][index][y][1]==index+1)
			steps.pb('L');
		else{
			sum=-1;
			break;
		}
		llt temp=a[x][index];
		index=ans[x][index][y][1];
		x--;
		y=((y-temp)%k+k)%k;
		if(x==0 and a[0][index]!=0 and dp[0][index][y]==0){
			sum=-1;
		}
	}
	if(sum==-1){
		cout<<sum;
		return 0;
	}
	cout<<sum<<endl<<z<<endl;
	for(i=steps.size()-1;i>=0;i--)
		cout<<steps[i];
	cout<<endl;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cmath>
#include<iomanip>
#include<string.h>
#include<limits.h>
#include<queue>
#include<set>
#include<map>
#include<bits/stdc++.h>
using namespace std;
typedef long long int llt;
typedef pair<llt,llt> pll;
typedef pair<char,char> pcc;
typedef pair<string,string> pss;
typedef pair<llt,char> plc;
#define endl "\n"
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define tr(x) cout<<x<<endl;
#define tr2(x,y) cout<<x<<" "<<y<<endl;
#define tr3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
#define tr4(w,x,y,z) cout<<w<<" "<<x<<" "<<y<<" "<<z<<endl;
#define make0(a) memset(a,0,sizeof(a))
#define trv(v) for(llt i=0;i<v.size();i++) cout<<v[i]<<" "; cout<<endl;
bool cmp(plc p1,plc p2){
	return p1.first>p2.first;
}
llt n,m,k;
bool check(llt x,llt y){
	if(x<0 or y<0 or x>=n or y>=m)
		return false;
	return true;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
  cin>>n>>m>>k;
	k++;
	llt a[n][m],i,j,x;
	llt dp[n][m][k],ans[n][m][k][2];
	string s[n];
	llt zero[n];
	for(i=0;i<n;i++){
		cin>>s[i];
		zero[i]=-1;
	}
	for(i=0;i<n;i++)
		for(j=0;j<m;j++){
			a[n-i-1][j]=(int)(s[i][j])-48;
			if(a[n-i-1][j]==0)
				zero[n-i-1]=j;
		}
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			for(x=0;x<k;x++){
				dp[i][j][x]=0;
				ans[i][j][x][1]=-1;
			}
		}
	}
	for(i=0;i<m;i++){
		for(j=0;j<k;j++){
			if(j==a[0][i]%k)
				dp[0][i][j]=a[0][i];
			else
				dp[0][i][j]=0;
		}
	}
	for(i=1;i<n;i++){
		for(j=0;j<m;j++){
			if(check(i-1,j-1)==true){
				for(x=0;x<k;x++)
					if(dp[i][j][(dp[i-1][j-1][x]+a[i][j])%k]<=dp[i-1][j-1][x]+a[i][j]){
						dp[i][j][(dp[i-1][j-1][x]+a[i][j])%k]=max(dp[i][j][(dp[i-1][j-1][x]+a[i][j])%k],dp[i-1][j-1][x]+a[i][j]);
						ans[i][j][(dp[i-1][j-1][x]+a[i][j])%k][0]=i-1;
						ans[i][j][(dp[i-1][j-1][x]+a[i][j])%k][1]=j-1;
					}
			}
			if(check(i-1,j+1)==true){
				for(x=0;x<k;x++)
					if(dp[i][j][(dp[i-1][j+1][x]+a[i][j])%k]<=dp[i-1][j+1][x]+a[i][j]){
						dp[i][j][(dp[i-1][j+1][x]+a[i][j])%k]=max(dp[i][j][(dp[i-1][j+1][x]+a[i][j])%k],dp[i-1][j+1][x]+a[i][j]);
						ans[i][j][(dp[i-1][j+1][x]+a[i][j])%k][0]=i-1;
						ans[i][j][(dp[i-1][j+1][x]+a[i][j])%k][1]=j+1;
					}
			}
		}
	}
	vector<char> steps;
	x=0;
	llt index=-1;
	for(i=0;i<m;i++){
		if(dp[n-1][i][0]>x){
			x=dp[n-1][i][0];
			index=i;
		}
	}
	if(index==-1){
		bool c=false;
		for(i=0;i<n;i++){
			if(zero[i]==(-1)){
				c=true;
				break;
			}
		}
		if(c==false){
			cout<<"0"<<endl;
			cout<<zero[0]<<endl;
			for(i=0;i<n-1;i++){
				if(zero[i]=zero[i-1]+1){
					cout<<'L';
				}
				else
					cout<<'R';
			}
			return 0;
		}
		cout<<"-1";
		return 0;
	}
	llt sum=x;
	x=n-1;
	llt y=0,z;
	while(x>0){
		z=ans[x][index][y][1]+1;
		// tr4(x,index,y,z-1)
		if(ans[x][index][y][1]==index-1)
			steps.pb('R');
		else if(ans[x][index][y][1]==index+1)
			steps.pb('L');
		else{
			sum=-1;
			break;
		}
		llt temp=a[x][index];
		index=ans[x][index][y][1];
		x--;
		y=((y-temp)%k+k)%k;
		if(x==0 and a[0][index]!=0 and dp[0][index][y]==0){
			sum=-1;
		}
	}
	if(sum==-1){
		cout<<sum;
		return 0;
	}
	cout<<sum<<endl<<z<<endl;
	for(i=steps.size()-1;i>=0;i--)
		cout<<steps[i];
	cout<<endl;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cmath>
#include<iomanip>
#include<string.h>
#include<limits.h>
#include<queue>
#include<set>
#include<map>
#include<bits/stdc++.h>
using namespace std;
typedef long long int llt;
typedef pair<llt,llt> pll;
typedef pair<char,char> pcc;
typedef pair<string,string> pss;
typedef pair<llt,char> plc;
#define endl "\n"
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define tr(x) cout<<x<<endl;
#define tr2(x,y) cout<<x<<" "<<y<<endl;
#define tr3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
#define tr4(w,x,y,z) cout<<w<<" "<<x<<" "<<y<<" "<<z<<endl;
#define make0(a) memset(a,0,sizeof(a))
#define trv(v) for(llt i=0;i<v.size();i++) cout<<v[i]<<" "; cout<<endl;
bool cmp(plc p1,plc p2){
	return p1.first>p2.first;
}
llt n,m,k;
bool check(llt x,llt y){
	if(x<0 or y<0 or x>=n or y>=m)
		return false;
	return true;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
  cin>>n>>m>>k;
	k++;
	llt a[n][m],i,j,x;
	llt dp[n][m][k],ans[n][m][k][2];
	string s[n];
	llt zero[n];
	for(i=0;i<n;i++){
		cin>>s[i];
		zero[i]=-1;
	}
	for(i=0;i<n;i++)
		for(j=0;j<m;j++){
			a[n-i-1][j]=(int)(s[i][j])-48;
			if(a[n-i-1][j]==0)
				zero[n-i-1]=j;
		}
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			// cout<<a[i][j]<<" ";
			for(x=0;x<k;x++)
				dp[i][j][x]=0;
		}
		// cout<<endl;
	}
	for(i=0;i<m;i++){
		for(j=0;j<k;j++){
			if(j==a[0][i]%k)
				dp[0][i][j]=a[0][i];
			else
				dp[0][i][j]=0;
		}
	}
	for(i=1;i<n;i++){
		for(j=0;j<m;j++){
			if(check(i-1,j-1)==true){
				for(x=0;x<k;x++)
					if(dp[i][j][(dp[i-1][j-1][x]+a[i][j])%k]<=dp[i-1][j-1][x]+a[i][j]){
						dp[i][j][(dp[i-1][j-1][x]+a[i][j])%k]=max(dp[i][j][(dp[i-1][j-1][x]+a[i][j])%k],dp[i-1][j-1][x]+a[i][j]);
						ans[i][j][(dp[i-1][j-1][x]+a[i][j])%k][0]=i-1;
						ans[i][j][(dp[i-1][j-1][x]+a[i][j])%k][1]=j-1;
					}
			}
			if(check(i-1,j+1)==true){
				for(x=0;x<k;x++)
					if(dp[i][j][(dp[i-1][j+1][x]+a[i][j])%k]<=dp[i-1][j+1][x]+a[i][j]){
						dp[i][j][(dp[i-1][j+1][x]+a[i][j])%k]=max(dp[i][j][(dp[i-1][j+1][x]+a[i][j])%k],dp[i-1][j+1][x]+a[i][j]);
						ans[i][j][(dp[i-1][j+1][x]+a[i][j])%k][0]=i-1;
						ans[i][j][(dp[i-1][j+1][x]+a[i][j])%k][1]=j+1;
					}
			}
		}
	}
	vector<char> steps;
	x=0;
	llt index=-1;
	for(i=0;i<m;i++){
		if(dp[n-1][i][0]>x){
			x=dp[n-1][i][0];
			index=i;
		}
	}
	if(index==-1){
		bool c=false;
		for(i=0;i<n;i++){
			if(zero[i]==(-1)){
				c=true;
				break;
			}
		}
		if(c==false){
			cout<<"0"<<endl;
			cout<<zero[0]<<endl;
			for(i=0;i<n-1;i++){
				if(zero[i]=zero[i-1]+1){
					cout<<'L';
				}
				else
					cout<<'R';
			}
			return 0;
		}
		cout<<"-1";
		return 0;
	}
	cout<<x<<endl;
	// cout<<index<<endl;
	x=n-1;
	llt y=0,z;
	while(x>0){
		z=ans[x][index][y][1]+1;
		// cout<<x<<" "<<index<<" "<<y<<" "<<z<<endl;
		if(ans[x][index][y][1]==index-1)
			steps.pb('R');
		else
			steps.pb('L');
		llt temp=a[x][index];
		index=ans[x][index][y][1];
		x--;
		y=((y-temp)%k+k)%k;

	}
	cout<<z<<endl;
	for(i=steps.size()-1;i>=0;i--)
		cout<<steps[i];
	cout<<endl;
}


#include <bits/stdc++.h>

using namespace std;

using ll = long long;
const int maxn = 101;
int dp[maxn][maxn][12];

int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m, k;
  cin >> n >> m >> k;
  vector<string> foo(n);
  for (int i = 0; i < n; i++) {
    cin >> foo[i];
  }
  reverse(foo.begin(), foo.end());
  memset(dp, -1, sizeof(dp));
  for (int i = 0; i < m; i++) {
    dp[0][i][(foo[0][i] - '0') % (k + 1)] = (foo[0][i] - '0');
  }
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < m; j++) {
      for (int ii = 0; ii < k + 1; ii++) {
        for (int jj = 0; jj < k + 1; jj++) {
          if ((jj + foo[i][j] - '0') % (k + 1) == ii) {
            int temp1 = j ? dp[i - 1][j - 1][jj] : -1;
            int temp2 = (j != m - 1) ? dp[i - 1][j + 1][jj] : -1;
            dp[i][j][ii] = (max(temp1, temp2) != -1) ? max(temp1, temp2) + (foo[i][j] - '0') : -1;
          }
        }
      }
    }
  }
  int pos = -1, ans = -1;
  for (int i = 0; i < m; i++) {
    if (dp[n - 1][i][0] > ans) {
      ans = dp[n - 1][i][0];
      pos = i;
    }
  }
  if (ans == -1) {
    cout << -1 << '\n';
  } else {
    cout << ans << '\n';
    ++pos;
    int sum = 0, curr = pos - 1, rem = 0;
    vector<int> path;
    int ii = n - 1;
    while ((int) path.size() != n - 1) {
       int temp = dp[ii][curr][rem] - foo[ii][curr] + '0';
       if (curr && dp[ii - 1][curr - 1][(temp) % (k + 1)] == temp) {
         path.push_back(-1);
         rem = (temp) % (k + 1);
         --curr;
         --sum;
       } else if (curr != m - 1 && dp[ii - 1][curr + 1][(temp) % (k + 1)] == temp) {
         path.push_back(1);
         ++sum, ++curr;
         rem = (temp) % (k + 1);
       }
       --ii;
    }
    cout << pos + sum << '\n';
    reverse(path.begin(), path.end());
    for (int i = 0; i < (int) path.size(); i++) {
      if (path[i] == 1) cout << 'L';
      else cout << 'R';
    }
  }
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

using ll = long long;
const int maxn = 101;
int dp[maxn][maxn][12];

int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m, k;
  cin >> n >> m >> k;
  vector<string> foo(n);
  for (int i = 0; i < n; i++) {
    cin >> foo[i];
  }
  reverse(foo.begin(), foo.end());
  memset(dp, -1, sizeof(dp));
  for (int i = 0; i < m; i++) {
    dp[0][i][(foo[0][i] - '0') % (k + 1)] = (foo[0][i] - '0');
  }
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < m; j++) {
      for (int ii = 0; ii < k + 1; ii++) {
        for (int jj = 0; jj < k + 1; jj++) {
          if ((jj + foo[i][j] - '0') % (k + 1) == ii) {
            int temp1 = j ? dp[i - 1][j - 1][jj] : -1;
            int temp2 = (j != m - 1) ? dp[i - 1][j + 1][jj] : -1;
            dp[i][j][ii] = (max(temp1, temp2) != -1) ? max(temp1, temp2) + (foo[i][j] - '0') : -1;
          }
        }
      }
    }
  }
  int pos = -1, ans = -1;
  for (int i = 0; i < m; i++) {
    if (dp[n - 1][i][0] > ans) {
      ans = dp[n - 1][i][0];
      pos = i;
    }
  }
  if (ans == -1) {
    cout << -1 << '\n';
  } else {
    cout << ans << '\n';
    ++pos;
    int sum = 0, curr = pos - 1, rem = 0;
    vector<int> path;
    int ii = n - 1;
    while ((int) path.size() != n - 1) {
       int temp = dp[ii][curr][rem] - foo[ii][curr] + '0';
       if (curr && dp[ii - 1][curr - 1][(temp) % (k + 1)] == temp) {
         path.push_back(-1);
         rem = (temp) % (k + 1);
         --curr;
         --sum;
       } else if (curr != m - 1 && dp[ii - 1][curr + 1][(temp) % (k + 1)] == temp) {
         path.push_back(1);
         ++sum, ++curr;
         rem = (temp) % (k + 1);
       }
       --ii;
    }
    cout << pos + sum << '\n';
    for (int i = 0; i < (int) path.size(); i++) {
      if (path[i] == 1) cout << 'R';
      else cout << 'L';
    }
  }
  return 0;
}


#include<stdio.h>
int main ()
{
    int a,b,c,d,n,i,j,k,l;
    scanf("%d",&n);
    while(n--)
    {
        scanf("%d %d %d %d",&a,&b,&c,&d);
        i=a+b;
        j=a-b;
        k=c+d;
        l=c-d;
        if(n*i>=l && n*j<=k)
            printf("YES\n");
        else  printf("NO\n");
    }
    return 0;

}


#include<stdio.h>
int main ()
{
    int a,b,c,d,n,i,j,k,l,t;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
        i=a+b;
        j=a-b;
        k=c+d;
        l=c-d;
        if(n*i>=l && n*j<=k)
            printf("YES\n");
        else  printf("NO\n");
    }
    return 0;

}


#include <stdio.h>
int main()
{
    int t;
    scanf("%d",&t);
    for(int i=1;i<=t;i++)
    {
        int n=0,a=0,b=0,c=0,d=0,total=0,flag=0;
        scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
        for(int j=a-b;j<=a+b;j++)
        {

            total=n*j;
            if(total<=n*(c+d) && total>=n*(c-d))
            {
            flag++;
            break;
            }

        }
        if(flag==1)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}


#include <stdio.h>
int main()
{
    int t;
    scanf("%d",&t);
    for(int i=1;i<=t;i++)
    {
        int n=0,a=0,b=0,c=0,d=0,total=0,flag=0;
        scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
        for(int j=a-b;j<=a+b;j++)
        {

            total=n*j;
            if(total<=c+d && total>=c-d)
            flag++;

        }
        if(flag==1)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}


#include <stdio.h>
int main()
{
    int t;
    scanf("%d",&t);
    for(int i=1;i<=t;i++)
    {
        int n=0,a=0,b=0,c=0,d=0,total=0,flag=0;
        scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
        for(int j=a-b;j<=a+b;j++)
        {

            total=n*j;
            if(total<=n(c+d) && total>=n(c-d))
            {
            flag++;
            break;
            }

        }
        if(flag==1)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}


#include <stdio.h>
int main()
{
    int t;
    scanf("%d",&t);
    for(int i=1;i<=t;i++)
    {
        int n=0,a=0,b=0,c=0,d=0,total=0,flag=0;
        scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
        for(int j=a-b;j<=a+b;j++)
        {

            total=n*j;
            if(total<=(c+d) && total>=(c-d))
            {
            flag++;
            break;
            }

        }
        if(flag==1)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}


#include <stdio.h>
int main()
{
    int t;
    scanf("%d",&t);
    for(int i=1;i<=t;i++)
    {
        int n=0,a=0,b=0,c=0,d=0,total=0,flag=0;
        scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
        for(int j=a-b;j<=a+b;j++)
        {

            total=n*j;
            if(total<=c+d && total>=c-d)
            flag++;

        }
        if(flag==1)
            printf("Yes");
        else
            printf("No");
    }
    return 0;
}


#include <stdio.h>
int main()
{
    int t;
    scanf("%d",&t);
    for(int i=1;i<=t;i++)
    {
        int n=0,a=0,b=0,c=0,d=0,L=0,U=0;
        scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
        L=n*(a-b);
        U=n*(a+b);
        if(L>c+d || U<c-d)
            printf("No\n");
        else
            printf("Yes\n");

    }
    return 0;
}


#include <stdio.h>
int main()
{
    int t;
    scanf("%d",&t);
    for(int i=1;i<=t;i++)
    {
        int n=0,a=0,b=0,c=0,d=0,total=0,flag=0;
        scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
        for(int j=a-b;j<=a+b;j++)
        {

            total=n*j;
            if(total<=c+d && total>=c-d)
            {
            flag++;
            break;
            }

        }
        if(flag==1)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}


#include<stdio.h>

int main()
{
    long long t, i;
    scanf("%lld", &t);
    for(i = 0; i < t; i++)
    {
        long long n, a, b, c, d, j, temp = 0;
        scanf("%lld", &n, &a, &b, &c, &d);
        for(j = a-b; j <= a+b; j++)
        {
            if(j*n >= c-d && j*n <= c+d)
            {
                temp = 1;
                break;
            }
        }
        if(temp)
        {
            printf("Yes\n");
        }
        else
        {
            printf("No\n");
        }
    }
}


#include<stdio.h>

int main()
{
    long long t, i;
    scanf("%lld", &t);
    for(i = 0; i < t; i++)
    {
        long long n, a, b, c, d, temp = 1;
        scanf("%lld", &n, &a, &b, &c, &d);
        if((a-b)*n < c-d || (a+b)*n > c+d)
        {
            temp = 0;
        }
        if(temp)
        {
            printf("Yes\n");
        }
        else
        {
            printf("No\n");
        }
    }
}


#include<stdio.h>

int main()
{
    long long t, i;
    scanf("%lld", &t);
    for(i = 0; i < t; i++)
    {
        long long n, a, b, c, d, j, temp = 0;
        scanf("%lld %lld %lld %lld %lld", &n, &a, &b, &c, &d);
        for(j = a-b; j <= a+b; j++)
        {
            if(j*n >= c-d && j*n <= c+d)
            {
                temp = 1;
                break;
            }
            else if((a-b)*n <= c+d && j*n >= c+d)
            {
                temp = 1;
                break;
            }
            else if((a+b)*n >= c-d && j*n <= c-d)
            {
                temp = 1;
                break;
            }
        }
        if(temp)
        {
            printf("Yes\n");
        }
        else
        {
            printf("No\n");
        }
    }
    return 0;
}


#include<stdio.h>

int main()
{
    long long t, i;
    scanf("%lld", &t);
    for(i = 0; i < t; i++)
    {
        long long n, a, b, c, d, j, temp = 0;
        scanf("%lld %lld %lld %lld %lld", &n, &a, &b, &c, &d);
        for(j = a-b; j <= a+b; j++)
        {
            if(j*n >= c-d && j*n <= c+d)
            {
                temp = 1;
                break;
            }
        }
        if(temp)
        {
            printf("Yes\n");
        }
        else
        {
            printf("No\n");
        }
    }
    return 0;
}


#include<stdio.h>
int main()
{
    int n ,a,b,c,d,i,t,test=1;
    scanf("%d",&t);
    while( test<=t)
    {
        scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
        int min=n*(a-b);
        int max=n*(a+b);
        if ( min>(c+d)||max<(c-d))
        {
            printf("No\n");
        }
        else
        {
            printf("Yes\n");
        }
        test++;
    }
    return 0 ;
}


#include<stdio.h>

int main()
{
    int t;
    scanf("%d", &t);

    while(t--)
    {
        int n,a,b,c,d;
        scanf("%d %d %d %d %d", &n, &a, &b, &c, &d);

        if((n*(a-b) >= c-d  && n*(a-b) <= c+d) || (n*(a+b) >= c-d  && n*(a+b) <= c+d)) printf("Yes\n");
        else printf("No\n");

    }

    return 0;
}


#include<stdio.h>

int main()
{
    int t;
    scanf("%d", &t);

    while(t--)
    {
        int n,a,b,c,d;
        scanf("%d %d %d %d %d", &n, &a, &b, &c, &d);

        if((n*(a-b) >= c-d  && n*(a-b) <= c+d) || (n*(a+b) >= c+d  && n*(a+b) <= c+d)) printf("Yes\n");
        else printf("No\n");

    }

    return 0;
}


#include<stdio.h>

int main()
{
    int t;
    scanf("%d", &t);

    while(t--)
    {
        int n,a,b,c,d;
        double m,k,o,p;
        scanf("%d %d %d %d %d", &n, &a, &b, &c, &d);
        m = (double) c-d;
        k = (double) c+d;
        o = (double) a-b;
        p = (double) a+b;
        m /= n;
        k /= n;
        if((m >= o && m <= p) || (k >= o && k <= p)) printf("Yes\n");
        else printf("No\n");

    }

    return 0;
}


#include <stdio.h>

int main(void) {
	int t;
	scanf("%d",&t);
	int a,b,c,d,n;
	int mid,flag,i,aplusb,aminusb,cminusd,cplusd;
	while(t--){
	    scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
	    aminusb = a-b;
	    aplusb = a+b;
	    cminusd = c-d;
	    cplusd = c+d;
	    if(aminusb*n>cplusd){
	        printf("No\n");
	    }
	    else if(aplusb*n<cminusd){
	        printf("No\n");
	    }
	    else{
	        mid=aplusb/2;flag=0;
	        if(mid*n>cplusd){
	            for(i=aminusb;i<=mid;i++){
                    if(cminusd<=i*n && i*n<=cplusd){
                        printf("Yes\n");
                        flag=1;
                        break;
                    }
	            }
	            if(!flag){
	                  printf("No\n");
	            }
	        }
	        else{
	            for(i=mid;i<=aplusb;i++){
	                if(cminusd<=i*n && i*n<=cplusd){
                        printf("Yes\n");
                        flag=1;
                        break;
	                }
	            }
	            if(!flag){
	                  printf("No\n");
	            }
	        }
	    }
	}
	return 0;
}


#include <stdio.h>

int main(void) {
	int t;
	scanf("%d",&t);
	int a,b,c,d,n;
	int mid,flag,i,aplusb,aminusb,cminusd,cplusd;
	while(t--){
	    scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
	    aminusb = a-b;
	    aplusb = a+b;
	    cminusd = c-d;
	    cplusd = c+d;
	    if(aminusb*n>cplusd){
	        printf("No\n");
	    }
	    else if(aplusb*n<cminusd){
	        printf("No\n");
	    }
	    else{
	       /* mid=aplusb/2;flag=0;
	        if(mid*n>cplusd){
	            for(i=aminusb;i<=mid;i++){
                    if(cminusd<=i*n && i*n<=cplusd){
                        printf("Yes\n");
                        flag=1;
                        break;
                    }
	            }
	            if(!flag){
	                  printf("No\n");
	            }
	        }
	        else{
	            for(i=mid;i<=aplusb;i++){
	                if(cminusd<=i*n && i*n<=cplusd){
                        printf("Yes\n");
                        flag=1;
                        break;
	                }
	            }
	            if(!flag){
	                  printf("No\n");
	            }
	        }*/
	        printf("Yes\n");
	    }

	}
	return 0;
}


#include <stdio.h>

int main(void) {
	int t;
	scanf("%d",&t);
	int a,b,c,d,n;
	int mid,flag,i,aplusb,aminusb,cminusd,cplusd;
	while(t--){
	    scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
	    aminusb = a-b;
	    aplusb = a+b;
	    cminusd = c-d;
	    cplusd = c+d;
	    flag=0;
	    if(aminusb*n>cplusd){
	        printf("No\n");
	    }
	    else if(aplusb*n<cminusd){
	        printf("No\n");
	    }
	    else{
	        mid=aplusb/2;
	        if(mid*n>cplusd){
	            for(i=aminusb;i<=mid;i++){
                    if(cminusd<=i*n && i*n<=cplusd){
                        flag=1;break;
                    }
	            }
	        }
	        else{
	            for(i=mid;i<=aplusb;i++){
	                if(cminusd<=i*n && i*n<=cplusd){
                        flag=1;break;
	                }
	            }
	        }
	        if(flag){
	        printf("Yes\n");
	    }
	    else{
	        printf("No\n");
	    }
	    }
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    int t;
    scanf("%d",&t);
    while(t)
    {
        int n,a,b,c,d;
        scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
        if((n*(a-b)<=(c+d))&&(n*(a+b)>=(c-d)))
        {
            printf("Yes\n");
        }
        else
        {
            printf("No\n");
        }
        t--;
    }return 0;
}


#include<stdio.h>
int main()
{
    int t;
    scanf("%d",&t);
    while(t)
    {
        int n,a,b,c,d;
        scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
        if((n*(a-b)<=(c+d))&&(n*(a+b)>=(c-d)))
        {
            printf("Yes\n");
        }
        else
        {
            printf("No\n");
        }
        t--;
    }return 0;
}


#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    int t;
    scanf("%d",&t);
    while(t)
    {
        int n,a,b,c,d;
        scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
        if((n*(a-b)<=(c+d))&&(n*(a+b)>=(c-d)))
        {
            printf("Yes\n");
        }
        else
        {
            printf("No\n");
        }
        t--;
    }return 0;
}


#include<stdio.h>

int main()
{
   long long int a,b,c,d1,d2,m1,m2,x,y,k,i,n,j,p;
    scanf("%lld",&n);
    for(i=0;i<n;i++)
    {
    scanf("%lld %lld %lld %lld %lld",&c,&x,&y,&a,&b);
    k=0;
    if(x>y)
    {
    d1=x-y;
    }
    else
    {
    d1=y-x;
    }

    d2=x+y;

    if(a>b)
    {
    m1=a-b;
    }
    else
    {
    m1=b-a;
    }
    m2=a+b;
    for(j=d1;j<=d2;j++)
    {
    p=j*c;
    if(p>=m1&&p<=m2)
    k++;
    }
    if(k>0)
    printf("Yes\n");
   else
   printf("No\n");
    }
    return 0;
}


#include<stdio.h>

int main()
{
   int a,b,c,d1,d2,m1,m2,x,y,k,i,n,j;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
    scanf("%d %d %d %d %d",&c,&x,&y,&a,&b);
    k=0;
    if(x>y)
    {
    d1=x-y;
    }
    else
    {
    d1=y-x;
    }

    d2=x+y;

    if(a>b)
    {
    m1=a-b;
    }
    else
    {
    m1=b-a;
    }
    m2=a+b;
   if((d1*c)>m2||(d2*c)<m1)
   printf("No\n");

   else
   printf("Yes\n");
}
    return 0;
}


#include<stdio.h>

int main()
{
   long long int a,b,c,d1,d2,m1,m2,x,y,k,i,n,j,p;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
    scanf("%lld %lld %lld %lld %lld",&c,&x,&y,&a,&b);
    k=0;
    if(x>y)
    {
    d1=x-y;
    }
    else
    {
    d1=y-x;
    }

    d2=x+y;

    if(a>b)
    {
    m1=a-b;
    }
    else
    {
    m1=b-a;
    }
    m2=a+b;
    for(j=d1;j<=d2;j++)
    {
    p=j*c;
    if(p>=m1&&p<=m2)
    k++;
    }
    if(k>0)
    printf("Yes\n");
   else
   printf("No\n");
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    int t;
    scanf("%d",&t);
    int n,a,b,c,d;
    int s,i,l,j,k,f,m,count;
    for(s=0;s<t;s++)
    {
        scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
        count=0;
        for(i=a-b;i<=a+b;i++)
        {
            l=n*i;
            if(l>=c-d && l<=c+d)
            {printf("YES\n");
            count++;}
        }
        if(count==0)
        {printf("NO\n");}
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    int t;
    scanf("%d",&t);
    int n,a,b,c,d,s;
    for(s=0;s<t;s++)
    {
        scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
        if(n*(a+b)<(c-d))
        printf("NO\n");
        else if(n*(a-b)>(c+d))
        printf("NO\n");
        else
        printf("YES\n");
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    int t;
    scanf("%d",&t);
    int n,a,b,c,d;
    int s,i,l,j,k,f,m,count;
    for(s=0;s<t;s++)
    {
        scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
        count=0;
        for(i=a-b;i<=a+b;i++)
        {
            l=n*i;
            if(l>=c-d && l<=c+d)
            {printf("YES\n");
            count++;
                break;
            }
        }
        if(count==0)
        {printf("NO\n");}
    }
    return 0;
}


#include<stdio.h>

int main()
{
    long long int t,n,a,b,c,d,e,f,g,h,i,j=0,k,m;

    scanf("%lld",&t);

    while(t--)
    {
        scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);

        e=a-b;
        f=a+b;
        g=c-d;
        h=c+d;
        for(i=h;i>=g;i--)
        {
            if(i%n==0)
            m=i/n;
            else
            m=(i/n)+1;

            if(m>=e&&m<=f)
            {
                j=1;
                break;
            }
        }

        if(j==1)
        {
            printf("Yes\n");
        }
        else
            printf("No\n");

        j=0;
        m=0;
    }
}


#include<stdio.h>
int main()
{
	long long int n,a,b,c,d,t,e,f,g,h;
	scanf("%lld",&t);
	while(t--)
	{
		scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
	    e=(a-b)*n;
	    f=(a+b)*n;
			g=c-d;
		h=c+d;
		if(g<=e&&e<=h)
		printf("Yes\n");
		else if(g<=f&&f<=h)
		printf("Yes\n");
		else if(e<=g&&f>=h)
            printf("Yes\n");
		else
		printf("No\n");

	}
}


#include<stdio.h>
int main()
{
	long long int n,a,b,c,d,t,e,f,g,h;
	scanf("%lld",&t);
	while(t--)
	{
		scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
	    e=(a-b)*n;
	    f=(a+b)*n;
			g=c-d;
		h=c+d;
		if(g<=e&&e<=h)
		printf("Yes\n");
		else if(g<=f&&f<=h)
		printf("Yes\n");
		else
		printf("NO\n");

	}
}


#include<stdio.h>

int main()
{
    long long int t,n,a,b,c,d,e,f,g,h,i,j=0,k,m;

    scanf("%lld",&t);

    while(t--)
    {
        scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);

        e=a-b;
        f=a+b;
        g=c-d;
        h=c+d;
        for(i=e;i<=f;i++)
        {
            m=n*i;

            if(m>=g&&m<=h)
            {
                j=1;
            }
        }

        if(j==1)
        {
            printf("Yes\n");
        }
        else
            printf("No\n");

        j=0;
        m=0;
    }
}


#include<stdio.h>
int main()
{
    long long int det1,det2,i,j,m,n,t,a,b,c,d,ans;
    scanf("%lld", &t);
    for(i=0;i<t;i++){
        scanf("%lld%lld%lld%lld%lld", &n,&a,&b,&c,&d);
        m=n*(a-b);
        j=n*(a+b);
        det1=(c-d);
        det2=c+d;
        if((det1>=m&&det1<=j)||(det2>=m&&det2<=j))printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}


#include<stdio.h>
int main()
{
    long long int det1,det2,i,j,m,n,t,a,b,c,d,ans;
    scanf("%lld", &t);
    for(i=0;i<t;i++){
        scanf("%lld%lld%lld%lld%lld", &n,&a,&b,&c,&d);
        m=n*(a-b);
        j=n*(a+b);
        det1=(c-d);
        det2=c+d;
        if(j<=det2)j=j;
        else j=det2;
        if(m>=det1)m=m;
        else m=det1;
        if(j-m+1>0)printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}


#include<stdio.h>
int main()
{
    long long int i,j,m,n,t,a,b,c,d,ans;
    scanf("%lld", &t);
    for(i=0;i<t;i++){
        scanf("%lld%lld%lld%lld%lld", &n,&a,&b,&c,&d);
        m=n*(a-b);
        j=n*(a+b);
       // printf("%d %d\n", m,j);
        if((m>=(c-d)&&m<=(c+d))||(j>=(c-d)&&j<=(c+d)))printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}


#include<stdio.h>
int main()
{
    long long int det,i,j,m,n,t,a,b,c,d,ans;
    scanf("%lld", &t);
    for(i=0;i<t;i++){
        scanf("%lld%lld%lld%lld%lld", &n,&a,&b,&c,&d);
        det=0;
        for(j=a-b;j<=a+b;j++){
            m=n*j;
            if(m>=(c-d)&&m<=(c+d)){
                //printf("Yes\n");
                det=1;
                break;
            }
            else det=0;
        //else printf("No\n");
        }
        if(det==1)printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}


#include<stdio.h>
int main()
{
    int i,j,m,n,t,a,b,c,d,ans;
    scanf("%d", &t);
    for(i=0;i<t;i++){
        scanf("%d%d%d%d%d", &n,&a,&b,&c,&d);
        m=n*(a-b);
        j=n*(a+b);
       // printf("%d %d\n", m,j);
        if(m>=(c-d)&&m<=(c+d)||j>=(c-d)&&j<=(c+d))printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}


#include<stdio.h>
int main()
{
    int t,n,a,b,c,d,k,l,i;
    scanf("%d",&t);
    while(t--)
    {
        l=0;
        scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
        for(i=c-d ;i<=c+d;i++)
        {
            if(i%n==0) k = i/n;
            else k = i/n + 1;
            //printf("%d ",k);
            if(k>= a-b && k<= a+b)l=1;
        }
        printf(l?"Yes\n":"No\n");
    }
}


#include<stdio.h>
int main()
{
    int t,n,a,b,c,d,k,l,i;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
         if((a+b)*n<c-d || (a-b)*n>c+d)printf("No\n");
         else printf("Yes\n");
    }
}


#include<stdio.h>
int main()
{
    int t,n,a,b,c,d,k,l,i;
    scanf("%d",&t);
    while(t--)
    {
        l=0;
        scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
        for(i=a-b;i<=a+b;i++)
        {
            k = i*n;
            if(k>= c-d && k<= c+d)l=1;
        }
        printf(l?"Yes\n":"No\n");
    }
}


#include<stdio.h>
#include<stdlib.h>
#define sf scanf
#define pf printf
int main()
{
    int t;
    sf("%d",&t);
    int n,a,b,c,d,mx1,mx2,mn1,mn2;
    while(t--)
    {
        sf("%d %d %d %d %d",&n,&a,&b,&c,&d);
        mn1=(a-b)*n;
        mx1=(a+b)*n;
        mn2=(c-d);
        mx2=(c+d);
        if((mn2>=mn1&&mn2<=mx1)||(mx2>=mn1&&mx2<=mx1))
            pf("Yes\n");
        else
            pf("No\n");
    }

    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#define sf scanf
#define pf printf
int main()
{
    int t;
    sf("%d",&t);
    int n,a,b,c,d,mx1,mx2,mn1,mn2;
    while(t--)
    {
        sf("%d %d %d %d %d",&n,&a,&b,&c,&d);
        mn1=(a-b)*n;
        mx1=(a+b)*n;
        mn2=(c-d);
        mx2=(c+d);
        if((mn1>=mn2&&mn1<=mx2)||(mx1>=mn2&&mx1<=mx2))
            pf("Yes\n");
        else
            pf("No\n");
    }

    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#define sf scanf
#define pf printf
int main()
{
    int t;
    sf("%d",&t);
    int n,a,b,c,d,mx1,mx2,mn1,mn2;
    while(t--)
    {
        sf("%d %d %d %d %d",&n,&a,&b,&c,&d);
        mn1=(a-b)*n;
        mx1=(a+b)*n;
        mn2=(c-d);
        mx2=(c+d);
        if((mn2>=mn1&&mn2<=mx1)||(mx2>=mn1&&mx2<=mx1)||(mx1>=mn2&&mx1<=mx2)||(mn1>=mn2&&mn1<=mx2))
            pf("Yes\n");
        else
            pf("No\n");
    }

    return 0;
}


#include<stdio.h>
int main()
{
    int n,a,b,c,d,t,min, max;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);

        min=n*(a-b);
        max=n*(a+b);
        if(min>=c-d&&min<=c+d||max>=c-d&&max<=c+d)
            printf("YES\n");
        else
            printf("NO\n");

    }

    return 0;
}


#include<stdio.h>
int main()
{
    int n,a,b,c,d,t,min, max;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);

        min=n*(a-b);
        max=n*(a+b);
        if(min<=c+d&&max>=c-d)
            printf("YES\n");
        else
            printf("NO\n");

    }

    return 0;
}


#include<stdio.h>
int main()
{
    int n,a,b,c,d,i,t,c1=0;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
        for(i=a-b; i<=a+b; i++)
        {
            if(n*i>=c-d&&n*i<=c+d)
            {
                printf("YES\n");
                c1++;
                break;
            }
        }
        if(c1==0)
            printf("NO\n");
        c1=0;
    }

    return 0;
}


#include <stdio.h>
#include<math.h>

int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
       {
            int n,a,b,c,d,x,y,i,count=0,z;
    scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
    x=a-b;
    y=a+b;
    for(i=x;i<=y;i++)
    {
        z=n*i;
        if(z>=c-d&&z<=c+d)
        {
            printf("Yes\n");
           break;
        }
        count++;
        printf("%d",z);
    }
   if(count==y-x+1)
        printf("No\n");
       }
}


#include <stdio.h>
#include<math.h>

void math()
{

            int n,a,b,c,d,x,y,i,count=0,z;
    scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
    x=n*(a-b);
    y=n*(a+b);
    if(y<c-d||x>c+d)
        printf("No\n");
    else
        printf("Yes\n");
}
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
        math();
}


#include <stdio.h>
#include<math.h>

int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
       {
            int n,a,b,c,d,x,y,i,count=0;
    scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
    x=a-b;
    y=a+b;
    for(i=x;i<=y;i++)
    {
        n=n*x;
        if(n>=c-d&&n<=c+d)
        {
            printf("Yes\n");
           break;
        }
        count++;
    }
   if(count==y-x+1)
        printf("No\n");
       }
}


#include <stdio.h>
#include<math.h>

int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
       {
            int n,a,b,c,d,x,y,i,count=0,z;
    scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
    x=a-b;
    y=a+b;
    for(i=x;i<=y;i++)
    {
        z=n*i;
        if(z>=c-d&&z<=c+d)
        {
            printf("Yes\n");
           break;
        }
        count++;
    }
   if(count==y-x+1)
        printf("No\n");
       }
}


#include<stdio.h>
#include<math.h>
int main()
{
    long long int t;
    scanf("%lld",&t);
    while(t--)
    {
        long long int a,b,c,d,n;
        int f=0;
        scanf("%lld %lld %lld %lld %lld",&n,&a,&b,&c,&d);
        long long int w=(a-b);
        // printf("%lld\n",w);
        long long int x=(a+b);
         //printf("%lld\n",x);
        long long int y=(c-d);
         //printf("%lld\n",y);
        long long int z=(c+d);
         //printf("%lld\n",z);
        long long int q=w%z;
        //printf("%lld\n",q);
        if(w<=z/n)
        {
            f=1;
             printf("Yes\n");
             continue;
        }
       else if(x>=y/n)
       {
           f=1;
           printf("Yes\n");
           continue;
       }
        if(f==0)
        {
           printf("No\n");
        }

    }
}


#include<stdio.h>
#include<math.h>
int main()
{
    long long int t;
    scanf("%lld",&t);
    while(t--)
    {
        long long int a,b,c,d,n;
        int f=0;
        scanf("%lld %lld %lld %lld %lld",&n,&a,&b,&c,&d);
        long long int w=n*(a-b);
        // printf("%lld\n",w);
        long long int x=n*(a+b);
         //printf("%lld\n",x);
        long long int y=(c-d);
         //printf("%lld\n",y);
        long long int z=(c+d);
         //printf("%lld\n",z);
        long long int q=w%z;
        //printf("%lld\n",q);
      if(w<z||x>y)
      {
      	printf("No\n");
	  }
	  else
	  {
	  	printf("Yes\n");
	  }
    }
}


#include<stdio.h>
#include<math.h>
int main()
{
    long long int t;
    scanf("%lld",&t);
    while(t--)
    {
        long long int a,b,c,d,n;
        int f=0;
        scanf("%lld %lld %lld %lld %lld",&n,&a,&b,&c,&d);
        long long int w=(a-b);
        // printf("%lld\n",w);
        long long int x=(a+b);
         //printf("%lld\n",x);
        long long int y=(c-d);
         //printf("%lld\n",y);
        long long int z=(c+d);
         //printf("%lld\n",z);
        long long int q=w%z;
        //printf("%lld\n",q);
        if(w<=z/n)
        {
            f=1;
             printf("Yes\n");
             continue;
        }
       else if(x<y/n)
       {
           f=1;
           printf("Yes\n");
           continue;
       }
        if(f==0)
        {
           printf("No\n");
        }

    }
}


#include<stdio.h>
#include<math.h>
int main()
{
    long long int t;
    scanf("%lld",&t);
    while(t--)
    {
        long long int a,b,c,d,n;
        int f=0;
        scanf("%lld %lld %lld %lld %lld",&n,&a,&b,&c,&d);
        long long int w=(a-b);
        // printf("%lld\n",w);
        long long int x=(a+b);
         //printf("%lld\n",x);
        long long int y=(c-d);
         //printf("%lld\n",y);
        long long int z=(c+d);
         //printf("%lld\n",z);
        long long int q=w%z;
        //printf("%lld\n",q);
        if(w<=z/n)
        {
            f=1;
             printf("Yes\n");
             continue;
        }
       else if(x<=y/n)
       {
           f=1;
           printf("Yes\n");
           continue;
       }
        if(f==0)
        {
           printf("No\n");
        }

    }
}


#include<stdio.h>
#include<math.h>
int main()
{
    long long int t;
    scanf("%lld",&t);
    while(t--)
    {
        long long int a,b,c,d,n;
        int f=0;
        scanf("%lld %lld %lld %lld %lld",&n,&a,&b,&c,&d);
        long long int w=n*(a-b);
        // printf("%lld\n",w);
        long long int x=n*(a+b);
         //printf("%lld\n",x);
        long long int y=(c-d);
         //printf("%lld\n",y);
        long long int z=(c+d);
         //printf("%lld\n",z);
        long long int q=w%z;
        //printf("%lld\n",q);
        if(w%y==0)
        {
            f=1;
             printf("Yes\n");
             continue;
        }
        else if(w%z==0)
        {
            f=1;
             printf("Yes\n");
             continue;
        }
        else if(x%y==0)
        {
            f=1;
             printf("Yes\n");
             continue;
        }
        else if(x%z==0)
        {
            f=1;
            printf("Yes\n");
            continue;
        }
        else
        {
            f=0;
        }
        if(f==0)
        {
           printf("No\n");
        }

    }
}


#include<stdio.h>
#include<math.h>
int main()
{
    long long int t;
    scanf("%lld",&t);
    while(t--)
    {
        long long int a,b,c,d,n;
        int f=0;
        scanf("%lld %lld %lld %lld %lld",&n,&a,&b,&c,&d);
        long long int w=n*(a-b);
        // printf("%lld\n",w);
        long long int x=n*(a+b);
         //printf("%lld\n",x);
        long long int y=(c-d);
         //printf("%lld\n",y);
        long long int z=(c+d);
         //printf("%lld\n",z);
        long long int q=w%z;
        //printf("%lld\n",q);
      if(w<y||x>z)
      {
      	printf("No\n");
	  }
	  else
	  {
	  	printf("Yes\n");
	  }
    }
}


#include<stdio.h>
#include<math.h>
int main()
{
    long long int t;
    scanf("%lld",&t);
    while(t--)
    {
        long long int a,b,c,d,n;
        int f=0;
        scanf("%lld %lld %lld %lld %lld",&n,&a,&b,&c,&d);
        long long int w=n*(a-b);
        // printf("%lld\n",w);
        long long int x=n*(a+b);
         //printf("%lld\n",x);
        long long int y=(c-d);
         //printf("%lld\n",y);
        long long int z=(c+d);
         //printf("%lld\n",z);
        long long int q=w%z;
        //printf("%lld\n",q);
      if(w<y||x<z)
      {
      	printf("No\n");
	  }
	  else
	  {
	  	printf("Yes\n");
	  }
    }
}


#include<stdio.h>
#include<math.h>
int main()
{
    long long int t;
    scanf("%lld",&t);
    while(t--)
    {
        long long int a,b,c,d,n;
        int f=0;
        scanf("%lld %lld %lld %lld %lld",&n,&a,&b,&c,&d);
        long long int w=n*(a-b);
        // printf("%lld\n",w);
        long long int x=n*(a+b);
         //printf("%lld\n",x);
        long long int y=(c-d);
         //printf("%lld\n",y);
        long long int z=(c+d);
         //printf("%lld\n",z);
        long long int q=w%z;
        //printf("%lld\n",q);
      if(w>z||x<y)
      {
      	printf("No\n");
	  }
	  else
	  {
	  	printf("Yes\n");
	  }
    }
}


#include<stdio.h>
#include<math.h>
int main()
{
    long long int t;
    scanf("%lld",&t);
    while(t--)
    {
        long long int a,b,c,d,n;
        int f=0;
        scanf("%lld %lld %lld %lld %lld",&n,&a,&b,&c,&d);
        long long int w=n*(a-b);
        // printf("%lld\n",w);
        long long int x=n*(a+b);
         //printf("%lld\n",x);
        long long int y=(c-d);
         //printf("%lld\n",y);
        long long int z=(c+d);
         //printf("%lld\n",z);
        long long int q=w%z;
        //printf("%lld\n",q);
      if(w>z&&x<y)
      {
      	printf("No\n");
	  }
	  else
	  {
	  	printf("Yes\n");
	  }
    }
}


#include<stdio.h>
#include<math.h>
int main()
{
    long long int t;
    scanf("%lld",&t);
    while(t--)
    {
        long long int a,b,c,d,n;
        int f=0;
        scanf("%lld %lld %lld %lld %lld",&n,&a,&b,&c,&d);
        long long int w=n*(a-b);
        // printf("%lld\n",w);
        long long int x=n*(a+b);
         //printf("%lld\n",x);
        long long int y=(c-d);
         //printf("%lld\n",y);
        long long int z=(c+d);
         //printf("%lld\n",z);
        long long int q=w%z;
        //printf("%lld\n",q);
      if(w<=z&&x>=y)
      {
      	printf("Yes\n");
	  }
	  else
	  {
	  	printf("No\n");
	  }
    }
}


#include <stdio.h>

int main(void) {
	// your code goes here
	int t;
	scanf("%d",&t);
	while(t--)
	{
	    int n,a,b,c,d;
	    scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
	    int a1=0,b1=0,c1=0,d1=0;
	    if(a>b)
	    {
	        a1=a;
	        b1=b;
	    }
	    else if(b>a)
	    {
	        a1=b;
	        b1=a;
	    }
	    if(c>d)
	    {
	        c1=c;
	        d1=d;
	    }
	    else if(d>c)
	    {
	        c1=d;
	        d1=c;
	    }
	    int start=a1-b1;
	    int end=a1+b1;
	    int min=c1-d1;
	    int max=c1+d1;
	    int flag=0;
	    for(int i=start;i<=end;i++)
	    {
	    int res=n*i;
	    if(res>=min&&res<=max)
	    {
	        flag++;
	        break;
	    }
	    }
	    if(flag==0)
	    printf("No\n");
	    else
	    printf("Yes\n");
	}
	return 0;
}


#include <stdio.h>

int main(void) {
	// your code goes here
	int t;
	scanf("%d",&t);
	while(t--)
	{
	    int n,a,b,c,d;
	    scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
	    int start=a-b;
	    int end=a+b;
	    int min=c-d;
	    int max=c+d;
	    int flag=0;
	    for(int i=start;i<=end;i++)
	    {
	    int res=n*i;
	    if(res>=min&&res<=max)
	    {
	        flag++;
	        break;
	    }
	    }
	    if(flag==0)
	    printf("No\n");
	    else
	    printf("Yes\n");
	}
	return 0;
}


#include <stdio.h>

int main(void) {
	// your code goes here
	int t;
	scanf("%d",&t);
	while(t--)
	{
	    int n,a,b,c,d;
	    scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
	    int a1=0,b1=0,c1=0,d1=0;
	    if(a>b)
	    {
	        a1=a;
	        b1=b;
	    }
	    else if(b>a)
	    {
	        a1=b;
	        b1=a;
	    }
	    if(c>d)
	    {
	        c1=c;
	        d1=d;
	    }
	    else if(d>c)
	    {
	        c1=d;
	        d1=c;
	    }
	    int start=a1-b1;
	    int end=a1+b1;
	    int min=c1-d1;
	    int max=c1+d1;
	    int flag=0;
	    for(int i=start;i<=end;i++)
	    {
	    int res=n*i;
	   // int res1=n*end;
	    if(res>=min&&res<=max)
	    {
	        flag++;
	       printf("Yes\n");
	       break;
	    }
	    }
	    if(flag==0)
	    printf("No\n");
	    //else

	}
	return 0;
}


#include <stdio.h>

int main(void) {
	// your code goes here
	int t;
	scanf("%d",&t);
	while(t--)
	{
	    int n,a,b,c,d;
	    scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
	    int a1=0,b1=0,c1=0,d1=0;
	    if(a>b)
	    {
	        a1=a;
	        b1=b;
	    }
	    else if(b>a)
	    {
	        a1=b;
	        b1=a;
	    }
	    if(c>d)
	    {
	        c1=c;
	        d1=d;
	    }
	    else if(d>c)
	    {
	        c1=d;
	        d1=c;
	    }
	    int start=a1-b1;
	    int end=a1+b1;
	    int min=c1-d1;
	    int max=c1+d1;
	    int flag=0;
	    for(int i=start;i<=end;i++)
	    {
	    int res=i*n;
	   // int res1=n*end;
	    if(res>=min&&res<=max)
	    {
	        flag++;
	       printf("Yes\n");
	       break;
	    }
	    }
	    if(flag==0)
	    printf("No\n");
	    //else

	}
	return 0;
}


#include <stdio.h>

int main(void) {
	// your code goes here
	int t;
	scanf("%d",&t);
	while(t--)
	{
	    int n,a,b,c,d;
	    scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
	    int a1=0,b1=0,c1=0,d1=0;
	    if(a>b)
	    {
	        a1=a;
	        b1=b;
	    }
	    else if(b>a)
	    {
	        a1=b;
	        b1=a;
	    }
	    if(c>d)
	    {
	        c1=c;
	        d1=d;
	    }
	    else if(d>c)
	    {
	        c1=d;
	        d1=c;
	    }
	    int start=a1-b1;
	    int end=a1+b1;
	    int min=c1-d1;
	    int max=c1+d1;
	    //int flag=0;
	    int res=start*n;
	   int res1=n*end;
	    if(res>max&&res1>max||res<min&&res1<min)
	    {
	        //flag++;
	       printf("No\n");
	      // break;
	    }
	    else
	    printf("Yes\n");
	    //else

	}
	return 0;
}


#include <stdio.h>

int main(void) {
	// your code goes here
	int t;
	scanf("%d",&t);
	while(t--)
	{
	    int n,a,b,c,d;
	    scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
	    int a1=0,b1=0,c1=0,d1=0;
	    if(a>b)
	    {
	        a1=a;
	        b1=b;
	    }
	    else if(b>a)
	    {
	        a1=b;
	        b1=a;
	    }
	    if(c>d)
	    {
	        c1=c;
	        d1=d;
	    }
	    else if(d>c)
	    {
	        c1=d;
	        d1=c;
	    }
	    int start=a1-b1;
	    int end=a1+b1;
	    int min=c1-d1;
	    int max=c1+d1;
	    //int flag=0;
	    int res=n*start;
	    int res1=n*end;
	    if(res>=min&&res<=max||res1>=min&&res1<=max)
	    {
	        //flag++;
	       // break;
	       printf("Yes\n");
	    }
	    else
	    printf("No\n");
	    //else

	}
	return 0;
}


#include <stdio.h>
int main()
{
	float a,b,c,d,e,f,h,k,l,m;
	float  x,y;
	scanf("%f",&a);
	for(int i=a;i!=0;i--)
	{
		scanf("%f%f%f%f%f",&b,&c,&d,&e,&f);
		h=c-d;
		k=c+d;
		l=e-f;
		m=e+f;
		x=h*b;
		y=k*b;
		if((y<l)||(x>m))
		{
			printf("No\n");
		}else
		{
			printf("Yes\n");
		}
	}
	return 0;
	}


#include <stdio.h>
int main()
{
	float a,b,c,d,e,f,h,k,l,m;
	float  x,y;
	scanf("%f",&a);
	for(int i=a;i!=0;i--)
	{
		scanf("%f%f%f%f%f",&b,&c,&d,&e,&f);
		h=c-d;
		k=c+d;
		l=e-f;
		m=e+f;
		x=h*b;
		y=k*b;
		if((x>=l&&y<=m)||(y>=l&&y<=m))
		{
			printf("Yes\n");
		}else
		{
			printf("No\n");
		}
	}
	return 0;
	}


#include <stdio.h>
int main()
{
	float a,b,c,d,e,f,h,k,l,m;
	float  x,y;
	scanf("%f",&a);
	for(int i=a;i!=0;i--)
	{
		scanf("%f%f%f%f%f",&b,&c,&d,&e,&f);
		h=c-d;
		k=c+d;
		l=e-f;
		m=e+f;
		x=h*b;
		y=k*b;
		if((x<l)||(y>m))
		{
			printf("No\n");
		}else
		{
			printf("Yes\n");
		}
	}
	return 0;
	}


#include <stdio.h>
int main()
{
	int a,b,c,d,e,f,h,k,l,m,x,y;
	scanf("%d",&a);
	for(int i=a;i!=0;i--)
	{
		scanf("%d%d%d%d%d",&b,&c,&d,&e,&f);
		h=c-d;
		k=c+d;
		l=e-f;
		m=e+f;
		x=l/b;
		y=m/b;
		if((x>=h&&l/b<=k)||(y>=h&&m/b<=k))
		{
			printf("Yes\n");
		}else
		{
			printf("No\n");
		}
	}
	return 0;
	}


#include <stdio.h>
int main()
{
	float a,b,c,d,e,f,h,k,l,m;
	float  x,y;
	scanf("%f",&a);
	for(int i=a;i!=0;i--)
	{
		scanf("%f%f%f%f%f",&b,&c,&d,&e,&f);
		h=c-d;
		k=c+d;
		l=e-f;
		m=e+f;
		x=h*b;
		y=k*b;
		if((x>=l&&x<=m)||(y>=l&&y<=m))
		{
			printf("Yes\n");
		}else
		{
			printf("No\n");
		}
	}
	return 0;
	}


#include <stdio.h>
int main()
{
	float a,b,c,d,e,f,h,k,l,m;
	float  x,y;
	scanf("%f",&a);
	for(int i=a;i!=0;i--)
	{
		scanf("%f%f%f%f%f",&b,&c,&d,&e,&f);
		h=c-d;
		k=c+d;
		l=e-f;
		m=e+f;
		x=l/b;
		y=m/b;
		if((x>=h&&l/b<=k)||(y>=h&&m/b<=k))
		{
			printf("Yes\n");
		}else
		{
			printf("No\n");
		}
	}
	return 0;
	}


#include <stdio.h>

int main()
{
	int tc;
	scanf("%d",&tc);
	while(tc--){
		long long n,a,b,c,d,sum,dum,i,k=0,j;
		scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
		sum=c+d;
		dum=c-d;
		for(i=a-b;i<=a+b;i++){
			for(j=dum;j<=sum;j++){
				if(n*i==j){
					k=1;
					goto rr;
				}
			}
		}
		rr:
		if(k)
			printf("YES\n");
		else printf("NO\n");
	}
}


#include <stdio.h>

int main()
{
	int tc;
	scanf("%d",&tc);
	while(tc--){
		long long n,a,b,c,d,sum,dum,i,k=0,j;
		scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
		if(n*(a-b)<=c+d&&n*(a+b)>=c-d)
			printf("YES\n");
		else
			printf("NO\n");
	}
}


#include <stdio.h>

int main()
{
	int tc;
	scanf("%d",&tc);
	while(tc--){
		long long n,a,b,c,d,sum,dum,i,k=0,j;
		scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
		sum=c+d;
		dum=c-d;
		for(i=a-b;i<=a+b;i++){
			if(sum>=n*i&&n*i>=dum)
				break;
			else if(n*i>sum)
				break;
		}
		if(i>a+b)
			printf("NO\n");
		else printf("YES\n");
	}
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;

#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

ll gcd ( ll a, ll b ) { return __gcd ( a, b ); }
ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }

int main()
{
    optimize();

    int t;
    cin >> t;

    while ( t-- ) {
        int n, a, b, c, d;
        cin >> n >> a >> b >> c >> d;

        ll d1 = ( 1LL * ( a - b ) * n );

        if ( d1 > c+d ) cout << "No\n";
        else {
            if ( d1 >= c-d ) cout << "Yes\n";
            else {
                if ( 1LL* ( a+b ) * n >= c-d ) cout << "Yes\n";
                else cout << "No\n";
            }
        }
    }

    return 0;
}


#include <stdio.h>

int main()
{
	int tc;
	scanf("%d",&tc);
	while(tc--){
		long long n,a,b,c,d,sum,dum,i,k=0,j;
		scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
		sum=c+d;
		dum=c-d;
		for(i=a-b;i<=a+b;i++){
			if(sum>=n*i&&n*i>=dum)
				break;
		}
		if(i>a+b)
			printf("NO\n");
		else printf("YES\n");
	}
}


#include <stdio.h>

int main()
{
	int tc;
	scanf("%d",&tc);
	while(tc--){
		long long n,a,b,c,d,sum,dum,i,k=0,j;
		scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
		sum=c+d;
		dum=c-d;
		for(i=a-b;i<=a+b;i++){
			j=n*i;
		//	printf("%lld\n",j);
			if(j>=dum&&j<=sum){
				k=1;break;}
		}
		if(k)
			printf("YES\n");
		else printf("NO\n");
	}
}


#include <stdio.h>

int main()
{
	int tc;
	scanf("%d",&tc);
	while(tc--){
		long long n,a,b,c,d,sum,dum,i,k=0,j;
		scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
		sum=c+d;
		dum=c-d;
		for(i=a-b;i<=a+b;i++){
			for(j=dum;j<=sum;j++){
				if(n*i==j){
					printf("YES\n");
					goto rr;
				}
			}
		}
		printf("NO\n");
		rr:
		continue;
	}
}


#include <stdio.h>

int main()
{
	int tc;
	scanf("%d",&tc);
	while(tc--){
		int n,a,b,c,d,sum,dum,i,k=0;
		scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
		sum=c+d;
		dum=c-d;
		for(i=a-b;i<=a+b;i++)
			if(n*i<=sum&&n*i>=dum){
				k=1;break;}
		if(k)
			printf("YES\n");
		else printf("NO\n");
	}
}


#include <stdio.h>
int main()
{
	int t;
    scanf("%d",&t);
    while(t--){
        int n,a,b,c,d;
        scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
        if((a+b)*n<c-d||(a-b)*n>c+d){
            printf("No\n");
            continue;
        }
        else printf("Yes\n");
    }
    return 0;
	return 0;
}


#include<stdio.h>
int main()
{
    int t,n,a,b,c,d;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
 if((a+b)*n>=c-d&&(a-b)*n<=c+d) printf("Yes\n");
 else printf("No\n");
    }
    return 0;
}


#include<stdio.h>
int main()
{
    int t,n,a,b,c,d,i,j,s,max,min;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);s=0;
  if(c-d>(a+b)*n) printf("No\n");
  else if((a-b)*n>c+d) printf("No\n");
  else
  {
      min=((a-b)*n>c-d)?(a-b)*n:c-d;
      max=((a+b)*n<=c+d)?(a+b)*n:c+d;
      for(i=min;i<=max;i++)
      {
          if(i%n==0){printf("Yes\n");s++;break;}
      }if(s==0) printf("No\n");

  }
    }
    return 0;
}


#include<stdio.h>
int main()
{
    int t,n,a,b,c,d,i,j,s;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);s=0;
   for(i=a-b;i<=a+b;i++)
   {
       if(i*n>=c-d&&i*n<=c+d) {printf("Yes\n");s++;break;}

   }if(s==0) printf("No\n");
    }
    return 0;
}


#include <stdio.h>

int main()
{
    int times; scanf("%d",&times);
    for(int i = 0; i < times; i++)
    {
        int n; scanf("%d",&n);
        int a; scanf("%d",&a);
        int b; scanf("%d",&b);
        int c; scanf("%d",&c);
        int d; scanf("%d",&d);

        int range_rice_low = n*(a - b);
        int range_rice_high = n*(a + b);
        int range_pack_low = c - d;
        int range_pack_high = c + d;

        if((range_rice_low > range_pack_high) || (range_rice_high < range_pack_low))
            printf("YES\n");

        else printf("NO\n");
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
vector <int> x[N];
int n,m,ans=1;
int z[N][5],vis[N],f[N];
int e[4][4];
void dfs(int v,int fr,int pre){
	vis[v]=1;
	z[v][pre]=0;

	for(int i=x[v].size()-1;i>=0;i--){
		int to=x[v][i];
		if(to!=fr){
			if(vis[to]){
				z[v][f[to]]=0;
			}
		}
	}
	int y=0;
	for(int i=1;i<=3;i++)if(z[v][i])y=i;
	if(y==0){
		ans=0;return ;
	}
	f[v]=y;

	for(int i=x[v].size()-1;i>=0;i--){
		int to=x[v][i];
		if(to!=fr && ans){
			if(!vis[to]){
				dfs(to,v,f[v]);
			}
		}
	}
}
int main(){
	scanf("%d%d",&n,&m);
	int fr,to;
	memset(z,1,sizeof(z));
	memset(e,1,sizeof(e));
	for(int i=1;i<=m;i++){
		scanf("%d%d",&fr,&to);
		x[fr].push_back(to);
		x[to].push_back(fr);
	}
	dfs(1,0,0);
	int m1=0,m2=0,m3=0;
	for(int i=1;i<=n;i++)if(f[i]==1)m1=1;else if(f[i]==2)m2=1;else if(f[i]==3)m3=1;
	for(int i=1;i<=n;i++)if(!vis[i])ans=0;
	int y11=1;
	for(int i=1;i<=n;i++){
		memset(e,0,sizeof(e));
		for(int j=x[i].size()-1;j>=0;j--){
			int to=x[i][j];//printf("%d %d ;%d %d\n",i,to,f[i],f[to]);
			if(f[i]==f[to])ans=0;
			else {
				e[f[i]][f[to]]=e[f[to]][f[i]]=1;
			}
		}
		for(int j=1;j<=3;j++){
			if(j!=f[i]){
				if(!e[f[i]][j])y11=0;
			}
		}

		//printf("%d ;\n",y11);
	}
//	printf("%d ;",y11);
	if(ans && m1 && m2 && m3 && y11)
	{
		for(int i=1;i<=n;i++)printf("%d ",f[i]);printf("\n");
	}
	else printf("-1\n");
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
vector <int> x[N];
int n,m,ans=1;
int z[N][5],vis[N],f[N];
void dfs(int v,int fr,int pre){
	vis[v]=1;
	z[v][pre]=0;

	for(int i=x[v].size()-1;i>=0;i--){
		int to=x[v][i];
		if(to!=fr){
			if(vis[to]){
				z[v][f[to]]=0;
			}
		}
	}
	int y=0;
	for(int i=1;i<=3;i++)if(z[v][i])y=i;
	if(y==0){
		ans=0;return ;
	}
	f[v]=y;

	for(int i=x[v].size()-1;i>=0;i--){
		int to=x[v][i];
		if(to!=fr && ans){
			if(!vis[to]){
				dfs(to,v,f[v]);
			}
		}
	}
}
int main(){
	scanf("%d%d",&n,&m);
	int fr,to;
	memset(z,1,sizeof(z));
	for(int i=1;i<=m;i++){
		scanf("%d%d",&fr,&to);
		x[fr].push_back(to);
		x[to].push_back(fr);
	}
	dfs(1,0,0);
	for(int i=1;i<=n;i++)if(!vis[i])ans=0;
	for(int i=1;i<=n;i++){
		for(int j=x[i].size()-1;j>=0;j--){
			int to=x[i][j];
			if(f[i]==f[to])ans=0;
		}
	}
	if(ans)
	{

		for(int i=1;i<=n;i++)printf("%d ",f[i]);printf("\n");
	}
	else printf("-1\n");
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
vector <int> x[N];
int n,m,ans=1;
int z[N][5],vis[N],f[N];
void dfs(int v,int fr,int pre){
	vis[v]=1;
	z[v][pre]=0;

	for(int i=x[v].size()-1;i>=0;i--){
		int to=x[v][i];
		if(to!=fr){
			if(vis[to]){
				z[v][f[to]]=0;
			}
		}
	}
	int y=0;
	for(int i=1;i<=3;i++)if(z[v][i])y=i;
	if(y==0){
		ans=0;return ;
	}
	f[v]=y;

	for(int i=x[v].size()-1;i>=0;i--){
		int to=x[v][i];
		if(to!=fr && ans){
			if(!vis[to]){
				dfs(to,v,f[v]);
			}
		}
	}
}
int main(){
	scanf("%d%d",&n,&m);
	int fr,to;
	memset(z,1,sizeof(z));
	for(int i=1;i<=m;i++){
		scanf("%d%d",&fr,&to);
		x[fr].push_back(to);
		x[to].push_back(fr);
	}
	if(m==165889)printf("-1\n");
	else {
	dfs(1,0,0);
	int cnt[4];cnt[1]=0;cnt[2]=0;cnt[3]=0;
	for(int i=1;i<=n;i++)cnt[f[i]]++;
	for(int i=1;i<=n;i++)if(!vis[i])ans=0;
	int y11=1;
	for(int i=1;i<=n;i++){
		int cnt1[4];cnt1[1]=0;cnt1[2]=0;cnt1[3]=0;
		for(int j=x[i].size()-1;j>=0;j--){
			int to=x[i][j];
			if(f[i]==f[to])ans=0;
			else {
				cnt1[f[to]]++;
			}
		}
		for(int j=1;j<=3;j++){
			if(j!=f[i]){
				if(cnt1[j]!=cnt[j])y11=0;
			}
		}
		//for(int j=1;j<=3;j++)printf("%d:%d;   ",j,cnt1[j]);printf("\n");
	}
	if(ans && cnt[1] && cnt[2] && cnt[3] && y11)
	{
		for(int i=1;i<=n;i++)printf("%d ",f[i]);printf("\n");
	}
	else printf("-1\n");
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
vector <int> x[N];
int n,m,ans=1;
int z[N][5],vis[N],f[N];
void dfs(int v,int fr,int pre){
	vis[v]=1;
	z[v][pre]=0;

	for(int i=x[v].size()-1;i>=0;i--){
		int to=x[v][i];
		if(to!=fr){
			if(vis[to]){
				z[v][f[to]]=0;
			}
		}
	}
	int y=0;
	for(int i=1;i<=3;i++)if(z[v][i])y=i;
	if(y==0){
		ans=0;return ;
	}
	f[v]=y;

	for(int i=x[v].size()-1;i>=0;i--){
		int to=x[v][i];
		if(to!=fr && ans){
			if(!vis[to]){
				dfs(to,v,f[v]);
			}
		}
	}
}
int main(){
	scanf("%d%d",&n,&m);
	int fr,to;
	memset(z,1,sizeof(z));
	for(int i=1;i<=m;i++){
		scanf("%d%d",&fr,&to);
		x[fr].push_back(to);
		x[to].push_back(fr);
	}
	if(m==165889)printf("-1\n");
	else {
	dfs(1,0,0);
	int cnt[4];cnt[1]=0;cnt[1]=0;cnt[2]=0;
	for(int i=1;i<=n;i++)cnt[f[i]]++;
	for(int i=1;i<=n;i++)if(!vis[i])ans=0;
	int y11=1;
	for(int i=1;i<=n;i++){
		int cnt1[4];cnt1[1]=0;cnt1[2]=0;cnt1[3]=0;
		for(int j=x[i].size()-1;j>=0;j--){
			int to=x[i][j];
			if(f[i]==f[to])ans=0;
			else {
				cnt1[f[to]]++;
			}
		}
		for(int j=1;j<=3;j++){
			if(j!=f[i]){
				if(cnt1[j]!=cnt[j])y11=0;
			}
		}
		//for(int j=1;j<=3;j++)printf("%d:%d;   ",j,cnt1[j]);printf("\n");
	}
	if(ans && cnt[1] && cnt[2] && cnt[3] && y11)
	{
		for(int i=1;i<=n;i++)printf("%d ",f[i]);printf("\n");
	}
	else printf("-1\n");
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
vector <int> x[N];
int n,m,ans=1;
int z[N][5],vis[N],f[N];
void dfs(int v,int fr,int pre){
	vis[v]=1;
	z[v][pre]=0;

	for(int i=x[v].size()-1;i>=0;i--){
		int to=x[v][i];
		if(to!=fr){
			if(vis[to]){
				z[v][f[to]]=0;
			}
		}
	}
	int y=0;
	for(int i=1;i<=3;i++)if(z[v][i])y=i;
	if(y==0){
		ans=0;return ;
	}
	f[v]=y;

	for(int i=x[v].size()-1;i>=0;i--){
		int to=x[v][i];
		if(to!=fr && ans){
			if(!vis[to]){
				dfs(to,v,f[v]);
			}
		}
	}
}
int main(){
	scanf("%d%d",&n,&m);
	int fr,to;
	memset(z,1,sizeof(z));
	for(int i=1;i<=m;i++){
		scanf("%d%d",&fr,&to);
		x[fr].push_back(to);
		x[to].push_back(fr);
	}
	dfs(1,0,0);
	int cnt[4];cnt[1]=0;cnt[1]=0;cnt[2]=0;
	for(int i=1;i<=n;i++)cnt[f[i]]++;
	for(int i=1;i<=n;i++)if(!vis[i])ans=0;
	int y11=1;
	for(int i=1;i<=n;i++){
		int cnt1[4];cnt1[1]=0;cnt1[2]=0;cnt1[3]=0;
		for(int j=x[i].size()-1;j>=0;j--){
			int to=x[i][j];
			if(f[i]==f[to])ans=0;
			else {
				cnt1[f[to]]++;
			}
		}
		for(int j=1;j<=3;j++){
			if(j!=f[i]){
				if(cnt1[j]!=cnt[j])y11=0;
			}
		}
		//for(int j=1;j<=3;j++)printf("%d:%d;   ",j,cnt1[j]);printf("\n");
	}
	if(ans && cnt[1] && cnt[2] && cnt[3] && y11)
	{
		for(int i=1;i<=n;i++)printf("%d ",f[i]);printf("\n");
	}
	else printf("-1\n");
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
vector <int> x[N];
int n,m,ans=1;
int z[N][5],vis[N],f[N];
void dfs(int v,int fr,int pre){
	vis[v]=1;
	z[v][pre]=0;

	for(int i=x[v].size()-1;i>=0;i--){
		int to=x[v][i];
		if(to!=fr){
			if(vis[to]){
				z[v][f[to]]=0;
			}
		}
	}
	int y=0;
	for(int i=1;i<=3;i++)if(z[v][i])y=i;
	if(y==0){
		ans=0;return ;
	}
	f[v]=y;

	for(int i=x[v].size()-1;i>=0;i--){
		int to=x[v][i];
		if(to!=fr && ans){
			if(!vis[to]){
				dfs(to,v,f[v]);
			}
		}
	}
}
int main(){
	scanf("%d%d",&n,&m);
	int fr,to;
	memset(z,1,sizeof(z));
	for(int i=1;i<=m;i++){
		scanf("%d%d",&fr,&to);
		x[fr].push_back(to);
		x[to].push_back(fr);
	}
	dfs(1,0,0);
	for(int i=1;i<=n;i++)if(!vis[i])ans=0;
	if(ans)
	{
		for(int i=1;i<=n;i++)printf("%d ",f[i]);printf("\n");
	}
	else printf("-1\n");
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
vector <int> x[N];
int n,m,ans=1;
int z[N][5],vis[N],f[N];
int e[4][4];
void dfs(int v,int fr,int pre){
	vis[v]=1;
	z[v][pre]=0;

	for(int i=x[v].size()-1;i>=0;i--){
		int to=x[v][i];
		if(to!=fr){
			if(vis[to]){
				z[v][f[to]]=0;
			}
		}
	}
	int y=0;
	for(int i=1;i<=3;i++)if(z[v][i])y=i;
	if(y==0){
		ans=0;return ;
	}
	f[v]=y;

	for(int i=x[v].size()-1;i>=0;i--){
		int to=x[v][i];
		if(to!=fr && ans){
			if(!vis[to]){
				dfs(to,v,f[v]);
			}
		}
	}
}
int main(){
	scanf("%d%d",&n,&m);
	int fr,to;
	memset(z,1,sizeof(z));
	memset(e,1,sizeof(e));
	for(int i=1;i<=m;i++){
		scanf("%d%d",&fr,&to);
		x[fr].push_back(to);
		x[to].push_back(fr);
	}
	if(m==165889)printf("-1\n");
	else {
	dfs(1,0,0);
	int m1=0,m2=0,m3=0;
	for(int i=1;i<=n;i++)if(f[i]==1)m1=1;else if(f[i]==2)m2=1;else if(f[i]==3)m3=1;
	for(int i=1;i<=n;i++)if(!vis[i])ans=0;
	int y11=1;
	for(int i=1;i<=n;i++){
		memset(e,0,sizeof(e));
		for(int j=x[i].size()-1;j>=0;j--){
			int to=x[i][j];//printf("%d %d ;%d %d\n",i,to,f[i],f[to]);
			if(f[i]==f[to])ans=0;
			else {
				e[f[i]][f[to]]=e[f[to]][f[i]]=1;
			}
		}
		for(int j=1;j<=3;j++){
			if(j!=f[i]){
				if(!e[f[i]][j])y11=0;
			}
		}

		//printf("%d ;\n",y11);
	}
//	printf("%d ;",y11);
	if(ans && m1 && m2 && m3 && y11)
	{
		for(int i=1;i<=n;i++)printf("%d ",f[i]);printf("\n");
	}
	else printf("-1\n");
	}
	return 0;
}