#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=(a),ed=(b);i<=ed;++i)
typedef long long ll;
inline int read(){
    register int x=0,f=1;register char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=0;ch=getchar();}
    while(isdigit(ch)){x=x*10+(ch^'0');ch=getchar();}
    return f?x:-x;
}

const int N=4e2+10,inf=0x3f3f3f3f;
int n1,n2,m,R,B,r[N],b[N];
int s,t,ns,nt,num=1,head[N],deg[N],dis[N],vis[N],pre[N],id[N],flow[N];
int f,c,sum;
char s1[N],s2[N];
struct edge{int to,val,flo,next;}e[N*10];
inline void add(int u,int v,int w,int f){
    e[++num]=(edge){v,w,f,head[u]},head[u]=num;
    e[++num]=(edge){u,-w,0,head[v]},head[v]=num;
}
inline void link(int u,int v,int w,int mn,int mx){
    add(u,v,w,mx-mn);
    deg[u]-=mn,deg[v]+=mn;
}

inline bool Bfs(){
    queue<int> q;
    memset(vis,0,sizeof(vis));memset(dis,0x3f,sizeof(dis));
    q.push(ns);dis[ns]=0,vis[ns]=1,flow[ns]=inf;
    while(!q.empty()){
	int u=q.front();q.pop();vis[u]=0;
	for(int i=head[u];i;i=e[i].next){
	    int v=e[i].to;if(!e[i].flo||dis[v]<=dis[u]+e[i].val)continue;
	    dis[v]=dis[u]+e[i].val;
	    id[v]=i;pre[v]=u;flow[v]=min(flow[u],e[i].flo);
	    if(!vis[v])vis[v]=1,q.push(v);
	}
    }
    return dis[t]<inf;
}
inline void Work(){
    int p=nt;f+=flow[nt];c+=dis[nt]*flow[nt];
    while(p^ns){e[id[p]].flo-=flow[nt],e[id[p]^1].flo+=flow[nt],p=pre[p];}
}

int main(){
    //freopen("in.in","r",stdin);
    n1=read(),n2=read(),m=read(),R=read(),B=read();
    s=n1+n2+1,t=s+1;ns=t+1,nt=t+2;
    scanf("%s%s",s1+1,s2+1);
    REP(t,1,m){
	int u=read(),v=read()+n1;
	link(u,v,R,0,1),r[t]=num;
	link(v,u,B,0,1),b[t]=num;
    }
    REP(i,1,n1){
	if(s1[i]=='R')link(s,i,0,1,inf);
	else if(s1[i]=='B')link(i,t,0,1,inf);
	else link(s,i,0,0,inf),link(i,t,0,0,inf);
    }
    REP(i,1,n2){
	if(s2[i]=='R')link(n1+i,t,0,1,inf);
	else if(s2[i]=='B')link(s,n1+i,0,1,inf);
	else link(s,n1+i,0,0,inf),link(n1+i,t,0,0,inf);
    }
    add(t,s,0,inf);
    REP(i,1,t){
	if(deg[i]>0)add(ns,i,0,deg[i]),sum+=deg[i];
	else add(i,nt,0,-deg[i]);
    }
    while(Bfs())
	Work();
    if(f!=sum){puts("-1");return 0;}
    printf("%d\n",c);
    REP(i,1,m){
	if(e[r[i]].flo)printf("R");
	else if(e[b[i]].flo)printf("B");
	else printf("U");
    }
    puts("");
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=(a),ed=(b);i<=ed;++i)
typedef long long ll;
inline int read(){
    register int x=0,f=1;register char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=0;ch=getchar();}
    while(isdigit(ch)){x=x*10+(ch^'0');ch=getchar();}
    return f?x:-x;
}

const int N=4e2+10,inf=0x3f3f3f3f;
int n1,n2,m,R,B,r[N],b[N];
int s,t,ns,nt,num=1,head[N],deg[N],dis[N],vis[N],pre[N],id[N],flow[N];
int f,c,sum;
char s1[N],s2[N];
struct edge{int to,val,flo,next;}e[N*10];
inline void add(int u,int v,int w,int f){
    e[++num]=(edge){v,w,f,head[u]},head[u]=num;
    e[++num]=(edge){u,-w,0,head[v]},head[v]=num;
}
inline void link(int u,int v,int w,int mn,int mx){
    add(u,v,w,mx-mn);
    deg[u]-=mn,deg[v]+=mn;
}

inline bool Bfs(){
    queue<int> q;
    memset(vis,0,sizeof(vis));memset(dis,0x3f,sizeof(dis));
    q.push(ns);dis[ns]=0,vis[ns]=1,flow[ns]=inf;
    while(!q.empty()){
	int u=q.front();q.pop();vis[u]=0;
	for(int i=head[u];i;i=e[i].next){
	    int v=e[i].to;if(!e[i].flo||dis[v]<=dis[u]+e[i].val)continue;
	    dis[v]=dis[u]+e[i].val;
	    id[v]=i;pre[v]=u;flow[v]=min(flow[u],e[i].flo);
	    if(!vis[v])vis[v]=1,q.push(v);
	}
    }
    return dis[nt]<inf;
}
inline void Work(){
    int p=nt;f+=flow[nt];c+=dis[nt]*flow[nt];
    while(p^ns){e[id[p]].flo-=flow[nt],e[id[p]^1].flo+=flow[nt],p=pre[p];}
}

int main(){
    //freopen("in.in","r",stdin);
    n1=read(),n2=read(),m=read(),R=read(),B=read();
    s=n1+n2+1,t=s+1;ns=t+1,nt=t+2;
    scanf("%s%s",s1+1,s2+1);
    REP(t,1,m){
	int u=read(),v=read()+n1;
	link(u,v,R,0,1),r[t]=num;
	link(v,u,B,0,1),b[t]=num;
    }
    REP(i,1,n1){
	if(s1[i]=='R')link(s,i,0,1,inf);
	else if(s1[i]=='B')link(i,t,0,1,inf);
	else link(s,i,0,0,inf),link(i,t,0,0,inf);
    }
    REP(i,1,n2){
	if(s2[i]=='R')link(n1+i,t,0,1,inf);
	else if(s2[i]=='B')link(s,n1+i,0,1,inf);
	else link(s,n1+i,0,0,inf),link(n1+i,t,0,0,inf);
    }
    add(t,s,0,inf);
    REP(i,1,t){
	if(deg[i]>0)add(ns,i,0,deg[i]),sum+=deg[i];
	else add(i,nt,0,-deg[i]);
    }
    while(Bfs())
	Work();
    if(f!=sum){puts("-1");return 0;}
    printf("%d\n",c);
    REP(i,1,m){
	if(e[r[i]].flo)printf("R");
	else if(e[b[i]].flo)printf("B");
	else printf("U");
    }
    puts("");
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int inf=1e9;
const int N=100010;
int n1,n2,m,r,b,S,T,SS,T_T,tot=1,ans;
int fi[N],ne[N],to[N],w[N];
int f[N],du[N],dis[N],pre[N];
char a[N],c[N];
bool v[N];
inline void add(int x,int y,int l,int r,int z){
	du[x]+=l; du[y]-=l;
	ne[++tot]=fi[x]; to[fi[x]=tot]=y; f[tot]=r-l; w[tot]=z;
	ne[++tot]=fi[y]; to[fi[y]=tot]=x; f[tot]=0; w[tot]=-z;
}
bool Spfa(){
	for(int i=0;i<=T_T;++i) dis[i]=inf,pre[i]=0;
	queue<int> s; s.push(SS); dis[SS]=0;
	while(!s.empty()){
		int x=s.front(); s.pop(); v[x]=false;
		for(int i=fi[x];i;i=ne[i]) if(dis[to[i]]>dis[x]+w[i]&&f[i]){
			dis[to[i]]=dis[x]+w[i]; pre[to[i]]=i;
			if(!v[to[i]]) v[to[i]]=true,s.push(to[i]);
		}
	}
	return dis[T_T]<inf;
}
int main(){
	cin>>n1>>n2>>m>>r>>b; S=n1+n2+1,T=n1+n2+2,SS=n1+n2+3,T_T=n1+n2+4;
	scanf("%s",a+1);
	scanf("%s",c+1);
	for(int i=1,x,y;i<=m;++i){
		cin>>x>>y;
		add(x,n1+y,0,1,r);
		add(n1+y,x,0,1,b);
	}
	for(int i=1;i<=n1;++i)
		if(a[i]=='R') add(S,i,1,inf,0);
		else if(a[i]=='B') add(i,T,1,inf,0);
		else add(S,i,0,inf,0),add(i,T,0,inf,0);
	for(int i=1;i<=n2;++i)
		if(c[i]=='B') add(S,n1+i,1,inf,0);
		else if(c[i]=='R') add(n1+i,T,1,inf,0);
		else add(S,n1+i,0,inf,0),add(n1+i,T,0,inf,0);
	add(T,S,0,inf,0);
	int sum=0;
	for(int i=1;i<=n1+n2+2;++i)
		if(du[i]>0) add(i,T_T,0,du[i],0),sum+=du[i];
		else if(du[i]<0) add(SS,i,0,-du[i],0);
	while(Spfa()){
		for(int i=pre[T_T];i;i=pre[to[i^1]]) ans+=w[i],f[i]--,f[i^1]++;
		--sum;
	}
	if(sum) return puts("-1")&0;
	cout<<ans<<endl;
	for(int i=2;i<=m*4+1;i+=4){
		if(f[i]&&f[i+2]) putchar('U');
		else if(f[i]) putchar('B');
		else putchar('R');
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int inf=1e9;
const int N=100010;
int n1,n2,m,r,b,S,T,SS,T_T,tot=1,ans;
int fi[N],ne[N],to[N],w[N];
int f[N],du[N],dis[N],pre[N];
char a[N],c[N];
bool v[N];
inline void add(int x,int y,int l,int r,int z){
	du[x]+=l; du[y]-=l;
	ne[++tot]=fi[x]; to[fi[x]=tot]=y; f[tot]=r-l; w[tot]=z;
	ne[++tot]=fi[y]; to[fi[y]=tot]=x; f[tot]=0; w[tot]=-z;
}
bool Spfa(){
	for(int i=0;i<=T_T;++i) dis[i]=inf,pre[i]=0;
	queue<int> s; s.push(SS); dis[SS]=0;
	while(!s.empty()){
		int x=s.front(); s.pop(); v[x]=false;
		for(int i=fi[x];i;i=ne[i]) if(dis[to[i]]>dis[x]+w[i]&&f[i]){
			dis[to[i]]=dis[x]+w[i]; pre[to[i]]=i;
			if(!v[to[i]]) v[to[i]]=true,s.push(to[i]);
		}
	}
	return dis[T_T]<inf;
}
int main(){
	cin>>n1>>n2>>m>>r>>b; S=n1+n2+1,T=n1+n2+2,SS=n1+n2+3,T_T=n1+n2+4;
	scanf("%s",a+1);
	scanf("%s",c+1);
	for(int i=1,x,y;i<=m;++i){
		cin>>x>>y;
		add(x,n1+y,0,1,r);
		add(n1+y,x,0,1,b);
	}
	for(int i=1;i<=n1;++i) if(a[i]=='R') add(S,i,1,inf,0); else if(a[i]=='B') add(i,T,1,inf,0); else add(S,i,0,inf,0),add(i,T,0,inf,0);
	for(int i=1;i<=n2;++i) if(c[i]=='B') add(S,n1+i,1,inf,0); else if(c[i]=='R') add(n1+i,T,1,inf,0); else add(S,n1+i,0,inf,0),add(n1+i,T,0,inf,0);
	add(T,S,0,inf,0);
	int sum=0;
	for(int i=1;i<=n1+n2+2;++i)
		if(du[i]>0) add(i,T_T,0,du[i],0),sum+=du[i];
		else if(du[i]<0) add(SS,i,0,-du[i],0);
	while(Spfa()){
		for(int i=pre[T_T];i;i=pre[to[i^1]]) ans+=w[i],f[i]--;
		--sum;
	}
	if(sum) return puts("-1")&0;
	cout<<ans<<endl;
	for(int i=2;i<=m*4+1;i+=4){
		if(f[i]&&f[i+2]) putchar('U');
		else if(f[i]) putchar('B');
		else putchar('R');
	}
	return 0;
}


#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
char cL[210],cR[210];
int Cost,fir[410],dis[1000010],nxt[1000010],w[1000010],cost[1000010],id=1;
void link(int a,int b,int c,int d){
	nxt[++id]=fir[a],fir[a]=id,dis[id]=b,w[id]=c,cost[id]=d;
	nxt[++id]=fir[b],fir[b]=id,dis[id]=a,w[id]=0,cost[id]=-d;
}
int S,T;
int que[200010],inq[410],cnt[410],hd,tl;
int dist[410],lst[410],E1[210],E2[210];
bool Mincost(){
	hd=tl=0;memset(cnt,0,sizeof cnt);que[tl++]=S;
	memset(dist,63,sizeof dist);dist[S]=0;
	while(hd^tl){
		int x=que[hd++];
		if(++cnt[x]==T){
			int Flow=1e9;
			for(int i=lst[x];dis[i^1]!=x;i=lst[dis[i^1]])Flow=std::min(Flow,w[i]);
			for(int i=lst[x];dis[i^1]!=x;i=lst[dis[i^1]])Cost+=cost[i]*Flow,w[i]-=Flow,w[i^1]+=Flow;
			return 1;
		}
		for(int i=fir[x];i;i=nxt[i])
			if(w[i]&&dist[dis[i]]>dist[x]+cost[i]){
				dist[dis[i]]=dist[x]+cost[i];lst[dis[i]]=i;
				if(!inq[dis[i]])inq[dis[i]]=1,que[tl++]=dis[i];
			}
		inq[x]=0;
	}
	if(dist[T]>=0)return 0;
	int Flow=1e9;
	for(int i=lst[T];i;i=lst[dis[i^1]])Flow=std::min(Flow,w[i]);
	for(int i=lst[T];i;i=lst[dis[i^1]])Cost+=cost[i]*Flow,w[i]-=Flow,w[i^1]+=Flow;
	return 1;
}
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int L=gi(),R=gi(),m=gi(),r=gi(),b=gi(),u,v;
	scanf("%s",cL+1);scanf("%s",cR+1);
	S=L+R+1,T=L+R+2;
	for(int i=1;i<=L;++i)
		if(cL[i]=='B')link(i,T,1,-100000),Cost+=100000,link(i,T,2333,0);
		else if(cL[i]=='R')link(S,i,1,-100000),Cost+=100000,link(S,i,2333,0);
		else link(S,i,2333,0),link(i,T,2333,0);
	for(int i=1;i<=R;++i)
		if(cR[i]=='R')link(i+L,T,1,-100000),Cost+=100000,link(i+L,T,2333,0);
		else if(cR[i]=='B')link(S,i+L,1,-100000),Cost+=100000,link(S,i+L,2333,0);
		else link(S,i+L,2333,0),link(i+L,T,2333,0);
	for(int i=1;i<=m;++i)u=gi(),v=gi(),link(u,v+L,1,r),E1[i]=id,link(v+L,u,1,b),E2[i]=id;
	while(Mincost());
	if(Cost>100000)Cost=-1;
	printf("%d\n",Cost);
	if(Cost!=-1)for(int i=1;i<=m;++i)putchar(w[E1[i]]?'R':w[E2[i]]?'B':'U');
	return 0;
}


import java.util.Scanner;

public class Deadline {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int tests = sc.nextInt();
    boolean[] result = new boolean[tests];
    for (int t = 0; t < tests; t++) {
      int n = sc.nextInt();
      int d = sc.nextInt();
      int s = (int) (Math.sqrt(d));
      result[t] = f(s - 1, d) <= n;
    }
    for (int t = 0; t < tests; t++) {
      if (result[t]) {
        System.out.println("YES");
      } else {
        System.out.println("NO");
      }
    }
  }

  private static int f(int x, int d) {
    if (d % (x + 1) == 0) {
      return x + d / (x + 1);
    } else {
      return x + d / (x + 1) + 1;
    }
  }
}


import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main implements Runnable, AutoCloseable {
    Scanner in = new Scanner(new BufferedInputStream(System.in));
    //    StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    PrintStream out = new PrintStream(new BufferedOutputStream(System.out));

    @Override
    public void run() {
        int t = in.nextInt();
        for (int i = 0; i < t; i++) {
            doOnce();
        }
    }

    private void doOnce() {
        int n = in.nextInt();
        int d = in.nextInt();
        int x = (int) Math.sqrt(d);
        if (test(n, d, x)
                || test(n, d, x - 1)
                || test(n, d, x + 1)
        ) {
            out.println("YES");
        } else {
            out.println("NO");
        }
    }

    private boolean test(int n, int d, int x) {
        if (x < 0) {
            return false;
        }
        int res = d / (x + 1);
        if (d % (x + 1) != 0) {
            res++;
        }
        res += x;
        return res <= n;
    }

    public static void main(String[] args) {
        try (Main main = new Main()) {
            main.run();
        }
    }

    @Override
    public void close() {
        out.close();
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class CodeForces {
    private final static FastReader in = new FastReader();
    private final static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int t = in.nextInt();
        double d, n, x = 0;
        boolean y = false;
        int res = 0;

        while (t-- > 0) {
            n = in.nextInt();
            d = in.nextInt();
            if (d <= n) {
                out.println("YES");

            } else {

                x = n - 1;
                res = (int) (Math.ceil(x + (d / (x + 1))));
                if (res <= n) {

                    out.println("YES");
                } else {
                    out.println("NO");
                }
            }

        }
        out.flush();
    }

    private static class FastReader {
        private static BufferedReader bf;
        private static StringTokenizer st;

        FastReader() {
            bf = new BufferedReader(new InputStreamReader(System.in));
            st = null;
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(bf.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class CodeForces {
    private final static FastReader in = new FastReader();
    private final static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int t = in.nextInt();
        double d, n, x = 0;
        boolean y = false;
        int res=0;

        while (t-- > 0) {
            n = in.nextInt();
            d = in.nextInt();
            if (d <= n) {
                out.println("YES");

            } else {
                while (x < n) {
                    x++;

                    res = (int) (Math.ceil(x + (d / (x + 1))));
                    if (res <= n) {
                        y = true;
                        break;
                    }
                }
                if (y) {
                    out.println("YES");
                } else {
                    out.println("NO");
                }
                x=0;
                y = false;
            }

        }
        out.flush();
    }

    private static class FastReader {
        private static BufferedReader bf;
        private static StringTokenizer st;

        FastReader() {
            bf = new BufferedReader(new InputStreamReader(System.in));
            st = null;
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(bf.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
    }
}


import java.util.Scanner;
public class Mathdemo {
    public static void main(String[] args) {
          long n,sum,t,i,d;
        Scanner input = new Scanner(System.in);
        t=input.nextInt();
        for(i=1;i<=t;i++){
         n=input.nextInt();
         d=input.nextInt();

         if(n*n+2*n+1>=d+d+d+d)
         {
             System.out.println("YES");
         }
         else{
             System.out.println("NO");
         }

         }

    }
   }


import java.util.Scanner;
public class Mathdemo {
    public static void main(String[] args) {
          int n,sum,t,i,d;
        Scanner input = new Scanner(System.in);
        t=input.nextInt();
        for(i=1;i<=t;i++){
         n=input.nextInt();
         d=input.nextInt();
         sum=n*n+2*n+1;
         if(sum>=4*d)
         {
             System.out.println("YES");
         }
         else{
             System.out.println("NO");
         }

         }

    }
   }


mport java.util.Scanner;
public class Mathdemo {
    public static void main(String[] args) {
          int n,sum,t,i,d;
        Scanner input = new Scanner(System.in);
        t=input.nextInt();
        for(i=1;i<=t;i++){
         n=input.nextInt();
         d=input.nextInt();
         sum=n*n+2*n+1;
         if(sum>=4*d)
         {
             System.out.println("YES");
         }
         else{
             System.out.println("NO");
         }

         }

    }
   }


import java.net.Inet4Address;
import java.util.*;
import java.io.*;
import java.text.*;
import java.math.*;

public class Main {
    public static FastIO file = new FastIO();

    private static void solve() {
        int t = nextInt();
        while (t-- > 0) {
            int n = nextInt(), d = nextInt();
            if (d <= n) {
                System.out.println("Yes");
                continue;
            }
            long x = 0, current = 0;
            for (int i = 0; i < n; i++) {
                n--;
                x++;
                current = (long)Math.ceil((float)d/(x+1));
                if (current <= n){
                    break;
                }
            }
            if (current <= n) System.out.println("yes");
            else System.out.println("no");
        }
    }

    private static int[] nextArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = nextInt();
        return a;
    }

    public static int[][] nextArray2D(int n, int m) {
        int[][] result = new int[n][];
        for (int i = 0; i < n; i++) {
            result[i] = nextArray(m);
        }
        return result;
    }

    public static long pow(long n, long p) {
        long ret = 1L;
        while (p > 0) {
            if (p % 2 != 0L)
                ret *= n;
            n *= n;
            p >>= 1L;
        }
        return ret;
    }

    public static String next() {
        return file.next();
    }

    public static int nextInt() {
        return file.nextInt();
    }

    public static long nextLong() {
        return file.nextLong();
    }

    public static double nextDouble() {
        return file.nextDouble();
    }

    public static String nextLine() {
        return file.nextLine();
    }

    public static class FastIO {
        BufferedReader br;
        StringTokenizer st;
        PrintWriter out;

        public FastIO() {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }

    public static void main(String[] args) throws IOException {
        solve();
    }

}


import java.net.Inet4Address;
import java.util.*;
import java.io.*;
import java.text.*;
import java.math.*;

public class Main {
    public static FastIO file = new FastIO();

    private static void solve() {
        int t = nextInt();
        while (t-- > 0) {
            int n = nextInt(), d = nextInt();
            if (d <= n) {
                System.out.println("Yes");
                continue;
            }
            long x = 0, current = 0;
            for (int i = 0; i < n; i++) {
                n--;
                x++;
                current = (long)Math.ceil((double)d/(x+1));
                if (current <= n){
                    break;
                }
            }
            if (current <= n) System.out.println("yes");
            else System.out.println("no");
        }
    }

    private static int[] nextArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = nextInt();
        return a;
    }

    public static int[][] nextArray2D(int n, int m) {
        int[][] result = new int[n][];
        for (int i = 0; i < n; i++) {
            result[i] = nextArray(m);
        }
        return result;
    }

    public static long pow(long n, long p) {
        long ret = 1L;
        while (p > 0) {
            if (p % 2 != 0L)
                ret *= n;
            n *= n;
            p >>= 1L;
        }
        return ret;
    }

    public static String next() {
        return file.next();
    }

    public static int nextInt() {
        return file.nextInt();
    }

    public static long nextLong() {
        return file.nextLong();
    }

    public static double nextDouble() {
        return file.nextDouble();
    }

    public static String nextLine() {
        return file.nextLine();
    }

    public static class FastIO {
        BufferedReader br;
        StringTokenizer st;
        PrintWriter out;

        public FastIO() {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }

    public static void main(String[] args) throws IOException {
        solve();
    }

}


import java.util.*;
import java.lang.*;
public class Main
{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while(t-->0){
		    int n = sc.nextInt();
		    int d = sc.nextInt();
		    int ans = 0;
		    if(d%(n/2 + 1)==0) ans = d/(n/2 + 1);
		    else ans = d/(n/2 + 1) + 1;
		    ans = ans + n/2;
		    if(ans>n) System.out.println("NO");
		    else System.out.println("YES");
		}
	}
}


import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{

	public static void main (String[] args)
	{
	    Scanner sc=new Scanner(System.in);
	    int tc=sc.nextInt();

	      for(int i=0;i<tc;i++)
	      {
	          int n=sc.nextInt();
	          int d=sc.nextInt();

	          if(d<=n)
	          {
	              System.out.println("YES");
	          }else
	          {
	              boolean flag=false;
	              for(int j=1;j<n;j++)
	          {
	              int temp=j+(int)Math.ceil(d/(j+1))+1;
	              // System.out.println(temp);
	               if(temp<=n)
	               {
	                   flag=true;
	                   break;
	               }

	          }
	          if(flag)
	               {
	                System.out.println("YES");
	               }else{
	                   System.out.println("NO");
	               }
	          }
	      }

	}
}


import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{

	public static void main (String[] args)
	{
	    Scanner sc=new Scanner(System.in);
	    int tc=sc.nextInt();

	      for(int i=0;i<tc;i++)
	      {
	          long n=sc.nextInt();
	          long d=sc.nextInt();

	          if(d<=n)
	          {
	              System.out.println("YES");
	          }else
	          {
	              boolean flag=false;
	              for(long j=1;j<n;j++)
	          {
	              long temp=j+(long)Math.ceil(d/(j+1))+1;

	               if(temp<=n)
	               {
	                   flag=true;
	                   break;
	               }

	          }
	          if(flag)
	               {
	                System.out.println("YES");
	               }else{
	                   System.out.println("NO");
	               }
	          }
	      }

	}
}


import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{

	public static void main (String[] args)
	{
	    Scanner sc=new Scanner(System.in);
	    int tc=sc.nextInt();

	      for(int i=0;i<tc;i++)
	      {
	          long n=sc.nextInt();
	          long d=sc.nextInt();

	          if(d<=n)
	          {
	              System.out.println("YES");
	          }else
	          {
	              boolean flag=false;
	              for(long j=1;j<n;j++)
	          {
	              long temp=j+(long)Math.ceil(d/(j+1))+1;
	               System.out.println(temp);
	               if(temp<=n)
	               {
	                   flag=true;
	                   break;
	               }

	          }
	          if(flag)
	               {
	                System.out.println("YES");
	               }else{
	                   System.out.println("NO");
	               }
	          }
	      }

	}
}


import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{

	public static void main (String[] args)
	{
	    Scanner sc=new Scanner(System.in);
	    int tc=sc.nextInt();

	      for(int i=0;i<tc;i++)
	      {
	          long n=sc.nextInt();
	          long d=sc.nextInt();

	          if(d<=n)
	          {
	              System.out.println("YES");
	          }else
	          {
	              boolean flag=false;
	              for(long j=1;j<n;j++)
	          {
	              double x=(double)d/(double)(j+1);
	              long temp=j+(long)Math.ceil(x);
	              // System.out.println(temp);
	               if(temp<=n)
	               {
	                   flag=true;
	                   break;
	               }

	          }
	          if(flag)
	               {
	                System.out.println("YES");
	               }else{
	                   System.out.println("NO");
	               }
	          }
	      }

	}
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Lovlin Thakkar
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        int testCount = Integer.parseInt(in.next());
        for (int i = 1; i <= testCount; i++)
            solver.solve(i, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int d = in.nextInt();

            if (d <= n) {
                out.println("YES");
            } else {
                int x = d - n;
                double o = ((double) d) / ((double) (x + 1));
                if (x + Math.ceil(o) <= n) {
                    out.println("YES");
                } else {
                    out.println("NO");
                }
            }

            out.flush();
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Lovlin Thakkar
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        int testCount = Integer.parseInt(in.next());
        for (int i = 1; i <= testCount; i++)
            solver.solve(i, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int d = in.nextInt();

            if (d <= n) {
                out.println("YES");
            } else {
                int x = (int) Math.sqrt(d) - 1;
                if (x <= d - n || x + 1 <= d - n) {
                    double o = ((double) d) / ((double) (x + 1));
                    if (x + Math.ceil(o) <= n) {
                        out.println("YES");
                    } else {
                        out.println("NO");
                    }
                } else {
                    x = d - n;
                    double o = ((double) d) / ((double) (x + 1));
                    if (x + Math.ceil(o) <= n) {
                        out.println("YES");
                    } else {
                        out.println("NO");
                    }
                }
            }

            out.flush();
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Lovlin Thakkar
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        int testCount = Integer.parseInt(in.next());
        for (int i = 1; i <= testCount; i++)
            solver.solve(i, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int d = in.nextInt();

            if (d <= n) {
                out.println("YES");
                out.flush();
            } else {
                int x = d - n;
                double o = d / (double) (x + 1);
                if (x + Math.ceil(o) <= n) {
                    out.println("YES");
                } else {
                    out.println("NO");
                }
            }

            out.flush();
        }

    }
}


package com.geeks4geeks.bs;

import java.io.*;

public class Deadline {

    public static void main(String[] args) throws IOException {
        try(InputReader in = new InputReader(System.in);
            OutputWriter out = new OutputWriter(System.out)) {
            int T = in.nextInt();
            while(T-- > 0) {
                int n = in.nextInt(), d = in.nextInt();

                int MAG = (int)Math.sqrt(d) + 10, x;
                for(x = 0; x < MAG; x++) {
                    if(x + (d + x) / (x + 1) <= n)
                        break;
                }

                out.printLine(x < MAG ? "YES" : "NO");
            }
        }
    }

    private static class InputReader implements AutoCloseable {

        /**
         * The default size of the InputReader's buffer is 216.
         */
        private static final int DEFAULT_BUFFER_SIZE = 1 << 16;

        /**
         * The default stream for the InputReader is standard input.
         */
        private static final InputStream DEFAULT_STREAM = System.in;

        /**
         * The maximum number of accurate decimal digits the method {@link #nextDoubleFast() nextDoubleFast()} can read.
         * Currently this value is set to 21 because it is the maximum number of digits a double precision float can have at the moment.
         */
        private static final int MAX_DECIMAL_PRECISION = 21;

        // 'c' is used to refer to the current character in the stream
        private int c;

        // Variables associated with the byte buffer.
        private byte[] buf;
        private int bufferSize, bufIndex, numBytesRead;

        private InputStream stream;

        // End Of File (EOF) character
        private static final byte EOF   = -1;

        // New line character: '\n'
        private static final byte NEW_LINE = 10;

        // Space character: ' '
        private static final byte SPACE = 32;

        // Dash character: '-'
        private static final byte DASH  = 45;

        // Dot character: '.'
        private static final byte DOT   = 46;

        // A reusable character buffer when reading string data.
        private char[] charBuffer;

        // Primitive data type lookup tables used for optimizations
        private static byte[] bytes = new byte[58];
        private static  int[] ints  = new int[58];
        private static char[] chars = new char[128];

        static {
            char ch = ' '; int value = 0; byte _byte = 0;
            for (int i = 48; i <  58; i++ ) bytes[i] = _byte++;
            for (int i = 48; i <  58; i++ )  ints[i] = value++;
            for (int i = 32; i < 128; i++ ) chars[i] = ch++;
        }

        // Primitive double lookup table used for optimizations.
        private static final double[][] doubles = {
                { 0.0d,0.00d,0.000d,0.0000d,0.00000d,0.000000d,0.0000000d,0.00000000d,0.000000000d,0.0000000000d,0.00000000000d,0.000000000000d,0.0000000000000d,0.00000000000000d,0.000000000000000d,0.0000000000000000d,0.00000000000000000d,0.000000000000000000d,0.0000000000000000000d,0.00000000000000000000d,0.000000000000000000000d },
                { 0.1d,0.01d,0.001d,0.0001d,0.00001d,0.000001d,0.0000001d,0.00000001d,0.000000001d,0.0000000001d,0.00000000001d,0.000000000001d,0.0000000000001d,0.00000000000001d,0.000000000000001d,0.0000000000000001d,0.00000000000000001d,0.000000000000000001d,0.0000000000000000001d,0.00000000000000000001d,0.000000000000000000001d },
                { 0.2d,0.02d,0.002d,0.0002d,0.00002d,0.000002d,0.0000002d,0.00000002d,0.000000002d,0.0000000002d,0.00000000002d,0.000000000002d,0.0000000000002d,0.00000000000002d,0.000000000000002d,0.0000000000000002d,0.00000000000000002d,0.000000000000000002d,0.0000000000000000002d,0.00000000000000000002d,0.000000000000000000002d },
                { 0.3d,0.03d,0.003d,0.0003d,0.00003d,0.000003d,0.0000003d,0.00000003d,0.000000003d,0.0000000003d,0.00000000003d,0.000000000003d,0.0000000000003d,0.00000000000003d,0.000000000000003d,0.0000000000000003d,0.00000000000000003d,0.000000000000000003d,0.0000000000000000003d,0.00000000000000000003d,0.000000000000000000003d },
                { 0.4d,0.04d,0.004d,0.0004d,0.00004d,0.000004d,0.0000004d,0.00000004d,0.000000004d,0.0000000004d,0.00000000004d,0.000000000004d,0.0000000000004d,0.00000000000004d,0.000000000000004d,0.0000000000000004d,0.00000000000000004d,0.000000000000000004d,0.0000000000000000004d,0.00000000000000000004d,0.000000000000000000004d },
                { 0.5d,0.05d,0.005d,0.0005d,0.00005d,0.000005d,0.0000005d,0.00000005d,0.000000005d,0.0000000005d,0.00000000005d,0.000000000005d,0.0000000000005d,0.00000000000005d,0.000000000000005d,0.0000000000000005d,0.00000000000000005d,0.000000000000000005d,0.0000000000000000005d,0.00000000000000000005d,0.000000000000000000005d },
                { 0.6d,0.06d,0.006d,0.0006d,0.00006d,0.000006d,0.0000006d,0.00000006d,0.000000006d,0.0000000006d,0.00000000006d,0.000000000006d,0.0000000000006d,0.00000000000006d,0.000000000000006d,0.0000000000000006d,0.00000000000000006d,0.000000000000000006d,0.0000000000000000006d,0.00000000000000000006d,0.000000000000000000006d },
                { 0.7d,0.07d,0.007d,0.0007d,0.00007d,0.000007d,0.0000007d,0.00000007d,0.000000007d,0.0000000007d,0.00000000007d,0.000000000007d,0.0000000000007d,0.00000000000007d,0.000000000000007d,0.0000000000000007d,0.00000000000000007d,0.000000000000000007d,0.0000000000000000007d,0.00000000000000000007d,0.000000000000000000007d },
                { 0.8d,0.08d,0.008d,0.0008d,0.00008d,0.000008d,0.0000008d,0.00000008d,0.000000008d,0.0000000008d,0.00000000008d,0.000000000008d,0.0000000000008d,0.00000000000008d,0.000000000000008d,0.0000000000000008d,0.00000000000000008d,0.000000000000000008d,0.0000000000000000008d,0.00000000000000000008d,0.000000000000000000008d },
                { 0.9d,0.09d,0.009d,0.0009d,0.00009d,0.000009d,0.0000009d,0.00000009d,0.000000009d,0.0000000009d,0.00000000009d,0.000000000009d,0.0000000000009d,0.00000000000009d,0.000000000000009d,0.0000000000000009d,0.00000000000000009d,0.000000000000000009d,0.0000000000000000009d,0.00000000000000000009d,0.000000000000000000009d }
        };

        /**
         * Create an InputReader that reads from standard input.
         */
        public InputReader () {
            this(DEFAULT_STREAM, DEFAULT_BUFFER_SIZE);
        }

        /**
         * Create an InputReader that reads from standard input.
         * @param bufferSize    The buffer size for this input reader.
         */
        public InputReader(int bufferSize) {
            this(DEFAULT_STREAM, bufferSize);
        }

        /**
         * Create an InputReader that reads from standard input.
         * @param stream  Takes an InputStream as a parameter to read from.
         */
        public InputReader(InputStream stream) {
            this(stream, DEFAULT_BUFFER_SIZE);
        }

        /**
         * Create an InputReader that reads from standard input.
         * @param  stream        Takes an {@link java.io.InputStream#InputStream() InputStream} as a parameter to read from.
         * @param  bufferSize    The size of the buffer to use.
         */
        public InputReader (InputStream stream, int bufferSize) {
            if (stream == null || bufferSize <= 0)
                throw new IllegalArgumentException();
            buf = new byte[bufferSize];
            charBuffer = new char[128];
            this.bufferSize = bufferSize;
            this.stream = stream;
        }

        /**
         * Reads a single character from the input stream.
         * @return Returns the byte value of the next character in the buffer and EOF
         * at the end of the stream.
         * @throws IOException throws exception if there is no more data to read
         */
        private byte read() throws IOException {

            if (numBytesRead == EOF) throw new IOException();

            if (bufIndex >= numBytesRead) {
                bufIndex = 0;
                numBytesRead = stream.read(buf);
                if (numBytesRead == EOF)
                    return EOF;
            }

            return buf[bufIndex++];
        }

        /**
         *  Read values from the input stream until you reach a character with a
         *  higher ASCII value than 'token'.
         * @param token The token is a value which we use to stop reading junk out of
         * the stream.
         * @return Returns 0 if a value greater than the token was reached or -1 if
         * the end of the stream was reached.
         * @throws IOException Throws exception at end of stream.
         */
        private int readJunk(int token) throws IOException {

            if (numBytesRead == EOF) return EOF;

            // Seek to the first valid position index
            do {

                while(bufIndex < numBytesRead) {
                    if (buf[bufIndex] > token) return 0;
                    bufIndex++;
                }

                // reload buffer
                numBytesRead = stream.read(buf);
                if (numBytesRead == EOF) return EOF;
                bufIndex = 0;

            } while(true);

        }

        /**
         * Reads a single byte from the input stream.
         * @return The next byte in the input stream
         * @throws IOException Throws exception at end of stream.
         */
        public byte nextByte() throws IOException {
            return (byte) nextInt();
        }

        /**
         * Reads a 32 bit signed integer from input stream.
         * @return The next integer value in the stream.
         * @throws IOException Throws exception at end of stream.
         */
        public int nextInt() throws IOException {

            if (readJunk(DASH-1) == EOF) throw new IOException();
            int sgn = 1, res = 0;

            c = buf[bufIndex];
            if (c == DASH) { sgn = -1; bufIndex++; }

            do {

                while(bufIndex < numBytesRead) {
                    if (buf[bufIndex] > SPACE) {
                        res = (res<<3)+(res<<1);
                        res += ints[buf[bufIndex++]];
                    } else {
                        bufIndex++;
                        return res*sgn;
                    }
                }

                // Reload buffer
                numBytesRead = stream.read(buf);
                if (numBytesRead == EOF) return res*sgn;
                bufIndex = 0;

            } while(true);

        }

        /**
         * Reads a 64 bit signed long from input stream.
         * @return The next long value in the stream.
         * @throws IOException Throws exception at end of stream.
         */
        public long nextLong() throws IOException {

            if (readJunk(DASH-1) == EOF) throw new IOException();
            int sgn = 1;
            long res = 0L;
            c = buf[bufIndex];
            if (c == DASH) { sgn = -1; bufIndex++; }

            do {

                while(bufIndex < numBytesRead) {
                    if (buf[bufIndex] > SPACE) {
                        res = (res<<3)+(res<<1);
                        res += ints[buf[bufIndex++]];
                    } else {
                        bufIndex++;
                        return res*sgn;
                    }
                }

                // Reload buffer
                numBytesRead = stream.read(buf);
                if (numBytesRead == EOF) return res*sgn;
                bufIndex = 0;

            } while(true);

        }

        /**
         * Doubles the size of the internal char buffer for strings
         */
        private void doubleCharBufferSize() {
            char[] newBuffer = new char[charBuffer.length << 1];
            for(int i = 0; i < charBuffer.length; i++) newBuffer[i] = charBuffer[i];
            charBuffer = newBuffer;
        }

        /**
         * Reads a line from the input stream.
         * @return Returns a line from the input stream in the form a String not
         * including the new line character. Returns null when there are
         * no more lines.
         * @throws IOException Throws IOException when something terrible happens.
         */
        public String nextLine() throws IOException {

            try { c=read(); } catch (IOException e) { return null; }
            if (c == NEW_LINE) return ""; // Empty line
            if (c == EOF) return null; // EOF

            int i = 0;
            charBuffer[i++] = (char)c;

            do {

                while(bufIndex < numBytesRead) {
                    if (buf[bufIndex] != NEW_LINE) {
                        if (i == charBuffer.length) doubleCharBufferSize();
                        charBuffer[i++] = (char) buf[bufIndex++];
                    } else {
                        bufIndex++;
                        return new String(charBuffer, 0, i);
                    }
                }

                // Reload buffer
                numBytesRead = stream.read(buf);
                if (numBytesRead == EOF)
                    return new String(charBuffer, 0, i);
                bufIndex = 0;

            } while(true);

        }

        // Reads a string of characters from the input stream.
        // The delimiter separating a string of characters is set to be:
        // any ASCII value <= 32 meaning any spaces, new lines, EOF, tabs...
        public String nextString() throws IOException {
            if (numBytesRead == EOF) return null;
            if (readJunk(SPACE) == EOF) return null;

            for(int i = 0;;) {
                while(bufIndex < numBytesRead) {
                    if (buf[bufIndex] > SPACE) {
                        if (i == charBuffer.length) doubleCharBufferSize();
                        charBuffer[i++] = (char) buf[bufIndex++];
                    } else {
                        bufIndex++;
                        return new String(charBuffer, 0, i);
                    }
                }

                // Reload buffer
                numBytesRead = stream.read(buf);
                if (numBytesRead == EOF) return new String(charBuffer, 0, i);
                bufIndex = 0;
            }
        }

        // Returns an exact value a double value from the input stream.
        public double nextDouble() throws IOException {
            String doubleVal = nextString();
            if (doubleVal == null) throw new IOException();
            return Double.valueOf(doubleVal);
        }

        // Very quickly reads a double value from the input stream (~3x faster than nextDouble()). However,
        // this method may provide a slightly less accurate reading than .nextDouble() if there are a lot
        // of digits (~16+). In particular, it will only read double values with at most 21 digits after
        // the decimal point and the reading my be as inaccurate as ~5*10^-16 from the true value.
        public double nextDoubleFast() throws IOException {
            c = read(); int sgn = 1;
            while (c <= SPACE) c = read(); // while c is either: ' ', '\n', EOF
            if (c == DASH) { sgn = -1; c = read(); }
            double res = 0.0;
            // while c is not: ' ', '\n', '.' or -1
            while (c > DOT) {res *= 10.0; res += ints[c]; c = read(); }
            if (c == DOT) {
                int i = 0; c = read();
                // while c is digit and we are less than the maximum decimal precision
                while (c > SPACE && i < MAX_DECIMAL_PRECISION) {
                    res += doubles[ints[c]][i++]; c = read();
                }
            }
            return res * sgn;
        }

        // Read an array of n byte values
        public byte[] nextByteArray(int n) throws IOException {
            byte[] ar = new byte[n];
            for (int i = 0; i < n; i++) ar[i] = nextByte();
            return ar;
        }

        // Read an integer array of size n
        public int[] nextIntArray(int n) throws IOException {
            int[] ar = new int[n];
            for (int i = 0; i < n; i++) ar[i] = nextInt();
            return ar;
        }

        // Read a long array of size n
        public long[] nextLongArray(int n) throws IOException {
            long[] ar = new long[n];
            for (int i = 0; i < n; i++) ar[i] = nextLong();
            return ar;
        }

        // read an of doubles of size n
        public double[] nextDoubleArray(int n) throws IOException {
            double[] ar = new double[n];
            for (int i = 0; i < n; i++) ar[i] = nextDouble();
            return ar;
        }

        // Quickly read an array of doubles
        public double[] nextDoubleArrayFast(int n) throws IOException {
            double[] ar = new double[n];
            for (int i = 0; i < n; i++) ar[i] = nextDoubleFast();
            return ar;
        }

        // Read a string array of size n
        public String[] nextStringArray(int n) throws IOException {
            String[] ar = new String[n];
            for (int i = 0; i < n; i++) {
                String str = nextString();
                if (str == null) throw new IOException();
                ar[i] = str;
            }
            return ar;
        }

        // Read a 1-based byte array of size n+1
        public byte[] nextByteArray1(int n) throws IOException {
            byte[] ar = new byte[n+1];
            for (int i = 1; i <= n; i++) ar[i] = nextByte();
            return ar;
        }

        // Read a 1-based integer array of size n+1
        public int[] nextIntArray1(int n) throws IOException {
            int[] ar = new int[n+1];
            for (int i = 1; i <= n; i++) ar[i] = nextInt();
            return ar;
        }

        // Read a 1-based long array of size n+1
        public long[] nextLongArray1(int n) throws IOException {
            long[] ar = new long[n+1];
            for (int i = 1; i <= n; i++) ar[i] = nextLong();
            return ar;
        }

        // Read a 1-based double array of size n+1
        public double[] nextDoubleArray1(int n) throws IOException {
            double[] ar = new double[n+1];
            for (int i = 1; i <= n; i++) ar[i] = nextDouble();
            return ar;
        }

        // Quickly read a 1-based double array of size n+1
        public double[] nextDoubleArrayFast1(int n) throws IOException {
            double[] ar = new double[n+1];
            for (int i = 1; i <= n; i++) ar[i] = nextDoubleFast();
            return ar;
        }

        // Read a 1-based string array of size n+1
        public String[] nextStringArray1(int n) throws IOException {
            String[] ar = new String[n+1];
            for (int i = 1; i <= n; i++) ar[i] = nextString();
            return ar;
        }

        // Read a two dimensional matrix of bytes of size rows x cols
        public byte[][] nextByteMatrix(int rows, int cols) throws IOException {
            byte[][] matrix = new byte[rows][cols];
            for(int i = 0; i < rows; i++)
                for (int j = 0; j < cols; j++)
                    matrix[i][j] = nextByte();
            return matrix;
        }

        // Read a two dimensional matrix of ints of size rows x cols
        public int[][] nextIntMatrix(int rows, int cols) throws IOException {
            int[][] matrix = new int[rows][cols];
            for(int i = 0; i < rows; i++)
                for (int j = 0; j < cols; j++)
                    matrix[i][j] = nextInt();
            return matrix;
        }

        // Read a two dimensional matrix of longs of size rows x cols
        public long[][] nextLongMatrix(int rows, int cols) throws IOException {
            long[][] matrix = new long[rows][cols];
            for(int i = 0; i < rows; i++)
                for (int j = 0; j < cols; j++)
                    matrix[i][j] = nextLong();
            return matrix;
        }

        // Read a two dimensional matrix of doubles of size rows x cols
        public double[][] nextDoubleMatrix(int rows, int cols) throws IOException {
            double[][] matrix = new double[rows][cols];
            for(int i = 0; i < rows; i++)
                for (int j = 0; j < cols; j++)
                    matrix[i][j] = nextDouble();
            return matrix;
        }

        // Quickly read a two dimensional matrix of doubles of size rows x cols
        public double[][] nextDoubleMatrixFast(int rows, int cols) throws IOException {
            double[][] matrix = new double[rows][cols];
            for(int i = 0; i < rows; i++)
                for (int j = 0; j < cols; j++)
                    matrix[i][j] = nextDoubleFast();
            return matrix;
        }

        // Read a two dimensional matrix of Strings of size rows x cols
        public String[][] nextStringMatrix(int rows, int cols) throws IOException {
            String[][] matrix = new String[rows][cols];
            for(int i = 0; i < rows; i++)
                for (int j = 0; j < cols; j++)
                    matrix[i][j] = nextString();
            return matrix;
        }

        // Read a 1-based two dimensional matrix of bytes of size rows x cols
        public byte[][] nextByteMatrix1(int rows, int cols) throws IOException {
            byte[][] matrix = new byte[rows+1][cols+1];
            for(int i = 1; i <= rows; i++)
                for (int j = 1; j <= cols; j++)
                    matrix[i][j] = nextByte();
            return matrix;
        }

        // Read a 1-based two dimensional matrix of ints of size rows x cols
        public int[][] nextIntMatrix1(int rows, int cols) throws IOException {
            int[][] matrix = new int[rows+1][cols+1];
            for(int i = 1; i <= rows; i++)
                for (int j = 1; j <= cols; j++)
                    matrix[i][j] = nextInt();
            return matrix;
        }

        // Read a 1-based two dimensional matrix of longs of size rows x cols
        public long[][] nextLongMatrix1(int rows, int cols) throws IOException {
            long[][] matrix = new long[rows+1][cols+1];
            for(int i = 1; i <= rows; i++)
                for (int j = 1; j <= cols; j++)
                    matrix[i][j] = nextLong();
            return matrix;
        }

        // Read a 1-based two dimensional matrix of doubles of size rows x cols
        public double[][] nextDoubleMatrix1(int rows, int cols) throws IOException {
            double[][] matrix = new double[rows+1][cols+1];
            for(int i = 1; i <= rows; i++)
                for (int j = 1; j <= cols; j++)
                    matrix[i][j] = nextDouble();
            return matrix;
        }

        // Quickly read a 1-based two dimensional matrix of doubles of size rows x cols
        public double[][] nextDoubleMatrixFast1(int rows, int cols) throws IOException {
            double[][] matrix = new double[rows+1][cols+1];
            for(int i = 1; i <= rows; i++)
                for (int j = 1; j <= cols; j++)
                    matrix[i][j] = nextDoubleFast();
            return matrix;
        }

        // Read a 1-based two dimensional matrix of Strings of size rows x cols
        public String[][] nextStringMatrix1(int rows, int cols) throws IOException {
            String[][] matrix = new String[rows+1][cols+1];
            for(int i = 1; i <= rows; i++)
                for (int j = 1; j <= cols; j++)
                    matrix[i][j] = nextString();
            return matrix;
        }

        // Closes the input stream
        public void close() throws IOException {
            stream.close();
        }

    }

    private static class OutputWriter implements AutoCloseable{
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0)
                    writer.print(' ');
                writer.print(objects[i]);
            }
        }

        public void printLine(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

        public void flush() {
            writer.flush();
        }

    }
}


import java.io.*;

public class Deadline {

    public static void main(String[] args) throws IOException {
        try(InputReader in = new InputReader(System.in);
            OutputWriter out = new OutputWriter(System.out)) {
            int T = in.nextInt();
            while(T-- > 0) {
                int n = in.nextInt(), d = in.nextInt();

                int MAG = (int)Math.sqrt(d) + 10, x;
                for(x = 0; x < MAG; x++) {
                    if(x + (d + x) / (x + 1) <= n)
                        break;
                }

                out.printLine(x < MAG ? "YES" : "NO");
            }
        }
    }

    private static class InputReader implements AutoCloseable {

        /**
         * The default size of the InputReader's buffer is 216.
         */
        private static final int DEFAULT_BUFFER_SIZE = 1 << 16;

        /**
         * The default stream for the InputReader is standard input.
         */
        private static final InputStream DEFAULT_STREAM = System.in;

        /**
         * The maximum number of accurate decimal digits the method {@link #nextDoubleFast() nextDoubleFast()} can read.
         * Currently this value is set to 21 because it is the maximum number of digits a double precision float can have at the moment.
         */
        private static final int MAX_DECIMAL_PRECISION = 21;

        // 'c' is used to refer to the current character in the stream
        private int c;

        // Variables associated with the byte buffer.
        private byte[] buf;
        private int bufferSize, bufIndex, numBytesRead;

        private InputStream stream;

        // End Of File (EOF) character
        private static final byte EOF   = -1;

        // New line character: '\n'
        private static final byte NEW_LINE = 10;

        // Space character: ' '
        private static final byte SPACE = 32;

        // Dash character: '-'
        private static final byte DASH  = 45;

        // Dot character: '.'
        private static final byte DOT   = 46;

        // A reusable character buffer when reading string data.
        private char[] charBuffer;

        // Primitive data type lookup tables used for optimizations
        private static byte[] bytes = new byte[58];
        private static  int[] ints  = new int[58];
        private static char[] chars = new char[128];

        static {
            char ch = ' '; int value = 0; byte _byte = 0;
            for (int i = 48; i <  58; i++ ) bytes[i] = _byte++;
            for (int i = 48; i <  58; i++ )  ints[i] = value++;
            for (int i = 32; i < 128; i++ ) chars[i] = ch++;
        }

        // Primitive double lookup table used for optimizations.
        private static final double[][] doubles = {
                { 0.0d,0.00d,0.000d,0.0000d,0.00000d,0.000000d,0.0000000d,0.00000000d,0.000000000d,0.0000000000d,0.00000000000d,0.000000000000d,0.0000000000000d,0.00000000000000d,0.000000000000000d,0.0000000000000000d,0.00000000000000000d,0.000000000000000000d,0.0000000000000000000d,0.00000000000000000000d,0.000000000000000000000d },
                { 0.1d,0.01d,0.001d,0.0001d,0.00001d,0.000001d,0.0000001d,0.00000001d,0.000000001d,0.0000000001d,0.00000000001d,0.000000000001d,0.0000000000001d,0.00000000000001d,0.000000000000001d,0.0000000000000001d,0.00000000000000001d,0.000000000000000001d,0.0000000000000000001d,0.00000000000000000001d,0.000000000000000000001d },
                { 0.2d,0.02d,0.002d,0.0002d,0.00002d,0.000002d,0.0000002d,0.00000002d,0.000000002d,0.0000000002d,0.00000000002d,0.000000000002d,0.0000000000002d,0.00000000000002d,0.000000000000002d,0.0000000000000002d,0.00000000000000002d,0.000000000000000002d,0.0000000000000000002d,0.00000000000000000002d,0.000000000000000000002d },
                { 0.3d,0.03d,0.003d,0.0003d,0.00003d,0.000003d,0.0000003d,0.00000003d,0.000000003d,0.0000000003d,0.00000000003d,0.000000000003d,0.0000000000003d,0.00000000000003d,0.000000000000003d,0.0000000000000003d,0.00000000000000003d,0.000000000000000003d,0.0000000000000000003d,0.00000000000000000003d,0.000000000000000000003d },
                { 0.4d,0.04d,0.004d,0.0004d,0.00004d,0.000004d,0.0000004d,0.00000004d,0.000000004d,0.0000000004d,0.00000000004d,0.000000000004d,0.0000000000004d,0.00000000000004d,0.000000000000004d,0.0000000000000004d,0.00000000000000004d,0.000000000000000004d,0.0000000000000000004d,0.00000000000000000004d,0.000000000000000000004d },
                { 0.5d,0.05d,0.005d,0.0005d,0.00005d,0.000005d,0.0000005d,0.00000005d,0.000000005d,0.0000000005d,0.00000000005d,0.000000000005d,0.0000000000005d,0.00000000000005d,0.000000000000005d,0.0000000000000005d,0.00000000000000005d,0.000000000000000005d,0.0000000000000000005d,0.00000000000000000005d,0.000000000000000000005d },
                { 0.6d,0.06d,0.006d,0.0006d,0.00006d,0.000006d,0.0000006d,0.00000006d,0.000000006d,0.0000000006d,0.00000000006d,0.000000000006d,0.0000000000006d,0.00000000000006d,0.000000000000006d,0.0000000000000006d,0.00000000000000006d,0.000000000000000006d,0.0000000000000000006d,0.00000000000000000006d,0.000000000000000000006d },
                { 0.7d,0.07d,0.007d,0.0007d,0.00007d,0.000007d,0.0000007d,0.00000007d,0.000000007d,0.0000000007d,0.00000000007d,0.000000000007d,0.0000000000007d,0.00000000000007d,0.000000000000007d,0.0000000000000007d,0.00000000000000007d,0.000000000000000007d,0.0000000000000000007d,0.00000000000000000007d,0.000000000000000000007d },
                { 0.8d,0.08d,0.008d,0.0008d,0.00008d,0.000008d,0.0000008d,0.00000008d,0.000000008d,0.0000000008d,0.00000000008d,0.000000000008d,0.0000000000008d,0.00000000000008d,0.000000000000008d,0.0000000000000008d,0.00000000000000008d,0.000000000000000008d,0.0000000000000000008d,0.00000000000000000008d,0.000000000000000000008d },
                { 0.9d,0.09d,0.009d,0.0009d,0.00009d,0.000009d,0.0000009d,0.00000009d,0.000000009d,0.0000000009d,0.00000000009d,0.000000000009d,0.0000000000009d,0.00000000000009d,0.000000000000009d,0.0000000000000009d,0.00000000000000009d,0.000000000000000009d,0.0000000000000000009d,0.00000000000000000009d,0.000000000000000000009d }
        };

        /**
         * Create an InputReader that reads from standard input.
         */
        public InputReader () {
            this(DEFAULT_STREAM, DEFAULT_BUFFER_SIZE);
        }

        /**
         * Create an InputReader that reads from standard input.
         * @param bufferSize    The buffer size for this input reader.
         */
        public InputReader(int bufferSize) {
            this(DEFAULT_STREAM, bufferSize);
        }

        /**
         * Create an InputReader that reads from standard input.
         * @param stream  Takes an InputStream as a parameter to read from.
         */
        public InputReader(InputStream stream) {
            this(stream, DEFAULT_BUFFER_SIZE);
        }

        /**
         * Create an InputReader that reads from standard input.
         * @param  stream        Takes an {@link java.io.InputStream#InputStream() InputStream} as a parameter to read from.
         * @param  bufferSize    The size of the buffer to use.
         */
        public InputReader (InputStream stream, int bufferSize) {
            if (stream == null || bufferSize <= 0)
                throw new IllegalArgumentException();
            buf = new byte[bufferSize];
            charBuffer = new char[128];
            this.bufferSize = bufferSize;
            this.stream = stream;
        }

        /**
         * Reads a single character from the input stream.
         * @return Returns the byte value of the next character in the buffer and EOF
         * at the end of the stream.
         * @throws IOException throws exception if there is no more data to read
         */
        private byte read() throws IOException {

            if (numBytesRead == EOF) throw new IOException();

            if (bufIndex >= numBytesRead) {
                bufIndex = 0;
                numBytesRead = stream.read(buf);
                if (numBytesRead == EOF)
                    return EOF;
            }

            return buf[bufIndex++];
        }

        /**
         *  Read values from the input stream until you reach a character with a
         *  higher ASCII value than 'token'.
         * @param token The token is a value which we use to stop reading junk out of
         * the stream.
         * @return Returns 0 if a value greater than the token was reached or -1 if
         * the end of the stream was reached.
         * @throws IOException Throws exception at end of stream.
         */
        private int readJunk(int token) throws IOException {

            if (numBytesRead == EOF) return EOF;

            // Seek to the first valid position index
            do {

                while(bufIndex < numBytesRead) {
                    if (buf[bufIndex] > token) return 0;
                    bufIndex++;
                }

                // reload buffer
                numBytesRead = stream.read(buf);
                if (numBytesRead == EOF) return EOF;
                bufIndex = 0;

            } while(true);

        }

        /**
         * Reads a single byte from the input stream.
         * @return The next byte in the input stream
         * @throws IOException Throws exception at end of stream.
         */
        public byte nextByte() throws IOException {
            return (byte) nextInt();
        }

        /**
         * Reads a 32 bit signed integer from input stream.
         * @return The next integer value in the stream.
         * @throws IOException Throws exception at end of stream.
         */
        public int nextInt() throws IOException {

            if (readJunk(DASH-1) == EOF) throw new IOException();
            int sgn = 1, res = 0;

            c = buf[bufIndex];
            if (c == DASH) { sgn = -1; bufIndex++; }

            do {

                while(bufIndex < numBytesRead) {
                    if (buf[bufIndex] > SPACE) {
                        res = (res<<3)+(res<<1);
                        res += ints[buf[bufIndex++]];
                    } else {
                        bufIndex++;
                        return res*sgn;
                    }
                }

                // Reload buffer
                numBytesRead = stream.read(buf);
                if (numBytesRead == EOF) return res*sgn;
                bufIndex = 0;

            } while(true);

        }

        /**
         * Reads a 64 bit signed long from input stream.
         * @return The next long value in the stream.
         * @throws IOException Throws exception at end of stream.
         */
        public long nextLong() throws IOException {

            if (readJunk(DASH-1) == EOF) throw new IOException();
            int sgn = 1;
            long res = 0L;
            c = buf[bufIndex];
            if (c == DASH) { sgn = -1; bufIndex++; }

            do {

                while(bufIndex < numBytesRead) {
                    if (buf[bufIndex] > SPACE) {
                        res = (res<<3)+(res<<1);
                        res += ints[buf[bufIndex++]];
                    } else {
                        bufIndex++;
                        return res*sgn;
                    }
                }

                // Reload buffer
                numBytesRead = stream.read(buf);
                if (numBytesRead == EOF) return res*sgn;
                bufIndex = 0;

            } while(true);

        }

        /**
         * Doubles the size of the internal char buffer for strings
         */
        private void doubleCharBufferSize() {
            char[] newBuffer = new char[charBuffer.length << 1];
            for(int i = 0; i < charBuffer.length; i++) newBuffer[i] = charBuffer[i];
            charBuffer = newBuffer;
        }

        /**
         * Reads a line from the input stream.
         * @return Returns a line from the input stream in the form a String not
         * including the new line character. Returns null when there are
         * no more lines.
         * @throws IOException Throws IOException when something terrible happens.
         */
        public String nextLine() throws IOException {

            try { c=read(); } catch (IOException e) { return null; }
            if (c == NEW_LINE) return ""; // Empty line
            if (c == EOF) return null; // EOF

            int i = 0;
            charBuffer[i++] = (char)c;

            do {

                while(bufIndex < numBytesRead) {
                    if (buf[bufIndex] != NEW_LINE) {
                        if (i == charBuffer.length) doubleCharBufferSize();
                        charBuffer[i++] = (char) buf[bufIndex++];
                    } else {
                        bufIndex++;
                        return new String(charBuffer, 0, i);
                    }
                }

                // Reload buffer
                numBytesRead = stream.read(buf);
                if (numBytesRead == EOF)
                    return new String(charBuffer, 0, i);
                bufIndex = 0;

            } while(true);

        }

        // Reads a string of characters from the input stream.
        // The delimiter separating a string of characters is set to be:
        // any ASCII value <= 32 meaning any spaces, new lines, EOF, tabs...
        public String nextString() throws IOException {
            if (numBytesRead == EOF) return null;
            if (readJunk(SPACE) == EOF) return null;

            for(int i = 0;;) {
                while(bufIndex < numBytesRead) {
                    if (buf[bufIndex] > SPACE) {
                        if (i == charBuffer.length) doubleCharBufferSize();
                        charBuffer[i++] = (char) buf[bufIndex++];
                    } else {
                        bufIndex++;
                        return new String(charBuffer, 0, i);
                    }
                }

                // Reload buffer
                numBytesRead = stream.read(buf);
                if (numBytesRead == EOF) return new String(charBuffer, 0, i);
                bufIndex = 0;
            }
        }

        // Returns an exact value a double value from the input stream.
        public double nextDouble() throws IOException {
            String doubleVal = nextString();
            if (doubleVal == null) throw new IOException();
            return Double.valueOf(doubleVal);
        }

        // Very quickly reads a double value from the input stream (~3x faster than nextDouble()). However,
        // this method may provide a slightly less accurate reading than .nextDouble() if there are a lot
        // of digits (~16+). In particular, it will only read double values with at most 21 digits after
        // the decimal point and the reading my be as inaccurate as ~5*10^-16 from the true value.
        public double nextDoubleFast() throws IOException {
            c = read(); int sgn = 1;
            while (c <= SPACE) c = read(); // while c is either: ' ', '\n', EOF
            if (c == DASH) { sgn = -1; c = read(); }
            double res = 0.0;
            // while c is not: ' ', '\n', '.' or -1
            while (c > DOT) {res *= 10.0; res += ints[c]; c = read(); }
            if (c == DOT) {
                int i = 0; c = read();
                // while c is digit and we are less than the maximum decimal precision
                while (c > SPACE && i < MAX_DECIMAL_PRECISION) {
                    res += doubles[ints[c]][i++]; c = read();
                }
            }
            return res * sgn;
        }

        // Read an array of n byte values
        public byte[] nextByteArray(int n) throws IOException {
            byte[] ar = new byte[n];
            for (int i = 0; i < n; i++) ar[i] = nextByte();
            return ar;
        }

        // Read an integer array of size n
        public int[] nextIntArray(int n) throws IOException {
            int[] ar = new int[n];
            for (int i = 0; i < n; i++) ar[i] = nextInt();
            return ar;
        }

        // Read a long array of size n
        public long[] nextLongArray(int n) throws IOException {
            long[] ar = new long[n];
            for (int i = 0; i < n; i++) ar[i] = nextLong();
            return ar;
        }

        // read an of doubles of size n
        public double[] nextDoubleArray(int n) throws IOException {
            double[] ar = new double[n];
            for (int i = 0; i < n; i++) ar[i] = nextDouble();
            return ar;
        }

        // Quickly read an array of doubles
        public double[] nextDoubleArrayFast(int n) throws IOException {
            double[] ar = new double[n];
            for (int i = 0; i < n; i++) ar[i] = nextDoubleFast();
            return ar;
        }

        // Read a string array of size n
        public String[] nextStringArray(int n) throws IOException {
            String[] ar = new String[n];
            for (int i = 0; i < n; i++) {
                String str = nextString();
                if (str == null) throw new IOException();
                ar[i] = str;
            }
            return ar;
        }

        // Read a 1-based byte array of size n+1
        public byte[] nextByteArray1(int n) throws IOException {
            byte[] ar = new byte[n+1];
            for (int i = 1; i <= n; i++) ar[i] = nextByte();
            return ar;
        }

        // Read a 1-based integer array of size n+1
        public int[] nextIntArray1(int n) throws IOException {
            int[] ar = new int[n+1];
            for (int i = 1; i <= n; i++) ar[i] = nextInt();
            return ar;
        }

        // Read a 1-based long array of size n+1
        public long[] nextLongArray1(int n) throws IOException {
            long[] ar = new long[n+1];
            for (int i = 1; i <= n; i++) ar[i] = nextLong();
            return ar;
        }

        // Read a 1-based double array of size n+1
        public double[] nextDoubleArray1(int n) throws IOException {
            double[] ar = new double[n+1];
            for (int i = 1; i <= n; i++) ar[i] = nextDouble();
            return ar;
        }

        // Quickly read a 1-based double array of size n+1
        public double[] nextDoubleArrayFast1(int n) throws IOException {
            double[] ar = new double[n+1];
            for (int i = 1; i <= n; i++) ar[i] = nextDoubleFast();
            return ar;
        }

        // Read a 1-based string array of size n+1
        public String[] nextStringArray1(int n) throws IOException {
            String[] ar = new String[n+1];
            for (int i = 1; i <= n; i++) ar[i] = nextString();
            return ar;
        }

        // Read a two dimensional matrix of bytes of size rows x cols
        public byte[][] nextByteMatrix(int rows, int cols) throws IOException {
            byte[][] matrix = new byte[rows][cols];
            for(int i = 0; i < rows; i++)
                for (int j = 0; j < cols; j++)
                    matrix[i][j] = nextByte();
            return matrix;
        }

        // Read a two dimensional matrix of ints of size rows x cols
        public int[][] nextIntMatrix(int rows, int cols) throws IOException {
            int[][] matrix = new int[rows][cols];
            for(int i = 0; i < rows; i++)
                for (int j = 0; j < cols; j++)
                    matrix[i][j] = nextInt();
            return matrix;
        }

        // Read a two dimensional matrix of longs of size rows x cols
        public long[][] nextLongMatrix(int rows, int cols) throws IOException {
            long[][] matrix = new long[rows][cols];
            for(int i = 0; i < rows; i++)
                for (int j = 0; j < cols; j++)
                    matrix[i][j] = nextLong();
            return matrix;
        }

        // Read a two dimensional matrix of doubles of size rows x cols
        public double[][] nextDoubleMatrix(int rows, int cols) throws IOException {
            double[][] matrix = new double[rows][cols];
            for(int i = 0; i < rows; i++)
                for (int j = 0; j < cols; j++)
                    matrix[i][j] = nextDouble();
            return matrix;
        }

        // Quickly read a two dimensional matrix of doubles of size rows x cols
        public double[][] nextDoubleMatrixFast(int rows, int cols) throws IOException {
            double[][] matrix = new double[rows][cols];
            for(int i = 0; i < rows; i++)
                for (int j = 0; j < cols; j++)
                    matrix[i][j] = nextDoubleFast();
            return matrix;
        }

        // Read a two dimensional matrix of Strings of size rows x cols
        public String[][] nextStringMatrix(int rows, int cols) throws IOException {
            String[][] matrix = new String[rows][cols];
            for(int i = 0; i < rows; i++)
                for (int j = 0; j < cols; j++)
                    matrix[i][j] = nextString();
            return matrix;
        }

        // Read a 1-based two dimensional matrix of bytes of size rows x cols
        public byte[][] nextByteMatrix1(int rows, int cols) throws IOException {
            byte[][] matrix = new byte[rows+1][cols+1];
            for(int i = 1; i <= rows; i++)
                for (int j = 1; j <= cols; j++)
                    matrix[i][j] = nextByte();
            return matrix;
        }

        // Read a 1-based two dimensional matrix of ints of size rows x cols
        public int[][] nextIntMatrix1(int rows, int cols) throws IOException {
            int[][] matrix = new int[rows+1][cols+1];
            for(int i = 1; i <= rows; i++)
                for (int j = 1; j <= cols; j++)
                    matrix[i][j] = nextInt();
            return matrix;
        }

        // Read a 1-based two dimensional matrix of longs of size rows x cols
        public long[][] nextLongMatrix1(int rows, int cols) throws IOException {
            long[][] matrix = new long[rows+1][cols+1];
            for(int i = 1; i <= rows; i++)
                for (int j = 1; j <= cols; j++)
                    matrix[i][j] = nextLong();
            return matrix;
        }

        // Read a 1-based two dimensional matrix of doubles of size rows x cols
        public double[][] nextDoubleMatrix1(int rows, int cols) throws IOException {
            double[][] matrix = new double[rows+1][cols+1];
            for(int i = 1; i <= rows; i++)
                for (int j = 1; j <= cols; j++)
                    matrix[i][j] = nextDouble();
            return matrix;
        }

        // Quickly read a 1-based two dimensional matrix of doubles of size rows x cols
        public double[][] nextDoubleMatrixFast1(int rows, int cols) throws IOException {
            double[][] matrix = new double[rows+1][cols+1];
            for(int i = 1; i <= rows; i++)
                for (int j = 1; j <= cols; j++)
                    matrix[i][j] = nextDoubleFast();
            return matrix;
        }

        // Read a 1-based two dimensional matrix of Strings of size rows x cols
        public String[][] nextStringMatrix1(int rows, int cols) throws IOException {
            String[][] matrix = new String[rows+1][cols+1];
            for(int i = 1; i <= rows; i++)
                for (int j = 1; j <= cols; j++)
                    matrix[i][j] = nextString();
            return matrix;
        }

        // Closes the input stream
        public void close() throws IOException {
            stream.close();
        }

    }

    private static class OutputWriter implements AutoCloseable{
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0)
                    writer.print(' ');
                writer.print(objects[i]);
            }
        }

        public void printLine(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

        public void flush() {
            writer.flush();
        }

    }
}