#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define ff first
#define ar array
#define ss second
#define ll long long int
#define mem(x) memset(x,0,sizeof(x))
#define setbits(x)  __builtin_popcount(x)
#define ull unsigned long long int
#define all(c) (c).begin(),(c).end()
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define db double
#define endl "\n"
#define  fbo(x) find_by_order(x)
#define  ook(x) order_of_key(x)
 
using namespace __gnu_pbds;
using namespace std;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair<ll,ll > iil;
typedef pair<ll,int> li;
typedef pair<int,int> ii;
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    os1;
typedef tree<int, null_type, greater<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    os2;

inline void fast()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
const ll pi=31;
const ll MOD[2] = {1187278649, 1149736019};//for double hashing
const ll mod=(ll)(1e9)+7;
ll pmod(ll x,ll n){
  ll r=1;
  while(n>0)
  {
    if(n&1LL)
      r=(r*x)%mod;
    x=(x*x)%mod;
    n=n/2;
    n%=mod;
  }
  return r;
}
ll pMod(ll x,ll n,ll mod)
{ ll r=1;
  while(n>0)
  {
    if(n&1LL)
      r=(r*x)%mod;
    x=(x*x)%mod;
    n=n/2;
    n%=mod;
  }
  return r;
 
}
 
//think recursively also;

void solve()
{  
  
   
 int n;
 cin>>n;
 int N=2*n;
 bool vis[N+1]={0};
 int a[n+1],b[n+1];
 bool flag=0;
 for(int i=1;i<=n;i++)
 {
  cin>>a[i]>>b[i];
  if(a[i]!=-1)
  {
     if(vis[a[i]])
     {
       flag=1;
     }
     vis[a[i]]=1;
  }
  if(b[i]!=-1)
  {
     if(vis[b[i]])
     {
      flag=1;
     }
     vis[b[i]]=1;
  }
   if(a[i]!=-1 && b[i]!=-1)
    {
      if(a[i]>=b[i])
      {
        flag=1;
      }
    }
 }

   if(flag)
   {
    cout<<"No\n";
    return;
   }
   for(int i=1;i<=n;i++)
    {
      for(int j=1;j<=n;j++)
      {

        if(i==j)
          continue;
        if(a[i]==-1 || b[i]==-1)
          continue;
        if(b[j]!=-1 && a[j]!=-1 && a[i]<=a[j] && a[j]<=b[i] && a[i]<=b[j] && b[j]<=b[i])
        {
          cout<<"No\n";
          return;
        }
        if(a[j]!=-1)
        {
            if(b[j]!=-1)
              {  
                 if(a[i]<=a[j] && a[j]<=b[i])
                 {if(abs(a[i]-b[i])!=abs(a[j]-b[j]))
                 {
                  cout<<"No\n";
                  return;
                 }
                }
              }
            else
            { 
              if(a[i]<=a[j] && a[j]<=b[i])
               {int g=b[i]-a[i];
               int req=g+a[j];
               if(req<=0 || req>N || vis[req])
               {
                cout<<"No\n";
                return;
               }
               //vis[req]=1;
             }
            }
        }
         if(b[j]!=-1)
         {
            if(a[j]!=-1)
              {   
                 if(a[i]<=b[j] && b[j]<=b[i])
                 {if(abs(a[i]-b[i])!=abs(a[j]-b[j]))
                 {
                  cout<<"No\n";
                  return;
                 }
                 }
              }
            else
            { 
              if(a[i]<=b[j] && b[j]<=b[i])
              {int g=b[i]-a[i];
               int req=b[j]-g;
               if(req<=0 || req>N || vis[req])
               {
                cout<<"No\n";
                return;
               }
              // vis[req]=1;
             }
            }
         }
      }
    }
    cout<<"Yes\n";
    return;


}
int main()
{
  fast();
   // int t;
   // cin>>t; 
   // for(int casee=1;casee<=t;casee++)
  {//cout<<"Case #"<<casee<<": ";
    solve();
  }
 
 
 
}
#pragma region head
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
template <class T>
using vv = vector<vector<T>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rrepi(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define bit(n) (1LL << (n))
template <class T>
inline bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const int INF = 1002003004;
const ll LINF = 1002003004005006007ll;
struct preprocess {
    preprocess() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} ____;
#pragma endregion head

#pragma region library
const int MOD = 1000000007;
struct mint {
    ll x;  // typedef long long ll;
    mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
    bool operator==(const mint a) const {
        return x == a.x;
    }
    bool operator!=(const mint a) const {
        return x != a.x;
    }
    friend ostream& operator<<(ostream& os, const mint& value) {
        os << value.x;
        return os;
    }
    friend istream& operator>>(istream& is, mint& value) {
        ll t;
        is >> t;
        value = mint(t);
        return is;
    }
};

#pragma endregion library

int main() {
    int _t;
    cin >> _t;
    while (_t--) {
        ll n, a, b;
        cin >> n >> a >> b;
        if(n<a+b){
            cout << 0 << '\n';
            continue;
        }
        mint ans = 0, sub = 0;
        ans = (mint)(n - a + 1) * (n - a + 1);
        ans *= (mint)(n - b + 1) * (n - b + 1);
        sub = (mint)(n - a + 1) * (n - b + 1) - (mint)(n - a - b + 2) * (n - a - b + 1);
        ans -= sub * sub;
        cout << ans << '\n';
    }
}
