#include using namespace std; #define fi first #define se second #define pb push_back #define mp make_pair #define SZ(x) ((int)x.size()) #define ALL(x) x.begin(),x.end() #define L(i,u) for (int i=head[u]; i; i=nxt[i]) #define rep(i,a,b) for (int i=(a); i<=(b); i++) #define per(i,a,b) for (int i=(a); i>=(b); i--) typedef long double ld; typedef long long ll; typedef unsigned int ui; typedef pair Pii; typedef vector Vi; template inline void read(T &x){ x=0; char c=getchar(); int f=1; while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();} while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f; } template T gcd(T a, T b){return !b?a:gcd(b,a%b);} template inline void umin(T &x, T y){x=x inline void umax(T &x, T y){x=x>y?x:y;} template inline T Abs(const T &x){return x>0?x:-x;} inline ui R() { static ui seed=416; return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13; } const int N = 2e6+11,mo=1e9+7; int n,st,p,inv[N],a[N],qz[N]; inline void add(int &x,int y){x=(x+y)%mo;} int qry(int n, int c){ if(n<=1)return 0; if(n==2)return 1; return (1+mo+qz[n-1+c]-qz[1+c])%mo; } int qryqz(int n,int c){return n<=1?0:1ll*(qry(n+1,c)-1+mo)*(c+n)%mo;} int main() { inv[1]=1;rep(i,2,N-1)inv[i]=1ll*(mo-mo/i)*inv[mo%i]%mo; rep(i,1,N-1)qz[i]=(qz[i-1]+inv[i])%mo; int T;read(T);while(T--){ read(n);read(st);read(p);if(p==1){p=n-p+1;st=n-st+1;} if(st==p){puts("0");continue;} if(p==n){printf("%d\n",qry(n-st+1,0));continue;} a[p]=0;int x,y; // x=0;per(i,p-1,1)a[i]=(1+1ll*x*inv[n-i])%mo,add(x,a[i]); // x=0;rep(i,p+1,n)a[i]=(1+1ll*x*inv[i-1])%mo,add(x,a[i]); int A=0,B=0; // rep(i,1,p-1)add(A,a[i]);rep(i,p+1,n)add(B,a[i]); A=qryqz(p,n-p);B=qryqz(n-p+1,p-1); x=(A+1ll*(p-1)*inv[n]%mo*(B-A+mo))%mo; y=(1ll*p*x%mo-A+mo)*inv[p-1]%mo; printf("%d\n",st==p?0:(st