# 题意

$(T \le 100 , 3 \le n \le 200, m \le 10000)$

# 题解

$u_i < u_j < v_i < v_j$

# 代码

/**************************************************************
Problem: 1997
Language: C++
Result: Accepted
Time:180 ms
Memory:10440 kb
****************************************************************/

#include <bits/stdc++.h>
#define For(i, l, r) for(register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Set(a, v) memset(a, v, sizeof(a))
using namespace std;

inline bool chkmin(int &a, int b) {return b < a ? a = b, 1 : 0;}
inline bool chkmax(int &a, int b) {return b > a ? a = b, 1 : 0;}

int x = 0, fh = 1; char ch = getchar();
for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
return x * fh;
}

void File() {
freopen ("1997.in", "r", stdin);
freopen ("1997.out", "w", stdout);
#endif
}

const int N = 110000 << 1, M = 100100 << 1;

struct Two_SAT {
#define Travel(i, u, v) for(int i = Head[u], v = to[i]; i; i = Next[i], v = to[i])
int Head[N], Next[M], to[M], e, n;

void add_edge(int u, int v) { to[++ e] = v; Next[e] = Head[u]; Head[u] = e; }

void Add(int x, int xv, int y, int yv) {
x = x << 1 | xv;
y = y << 1 | yv;
add_edge(y ^ 1, x ^ 1);
}

void Init(int n) {
this -> n = n; e = 0;
For (i, 1, n * 2 + 10) Head[i] = 0;
}

int sccno[N], scc_cnt;
int sta[N], top;
void Tarjan(int u) {
lowlink[u] = dfn[u] = ++ clk; sta[++ top] = u;
Travel(i, u, v)
++ scc_cnt;
for (;;) {
int x = sta[top --];
sccno[x] = scc_cnt;
if (x == u) break;
}
}
}

bool Solve() {
For (i, 1, n * 2 + 10)
dfn[i] = sccno[i] = lowlink[i] = 0;
scc_cnt = clk = top = 0;
For (i, 1, n * 2 + 1)
if (!dfn[i]) Tarjan(i);
For (i, 1, n)
if (sccno[i << 1] == sccno[i << 1 | 1]) return false;
return true;
}
} T;

struct Edge{
int u, v;
inline bool operator < (const Edge &rhs) const {
return (u ^ rhs.u) ? u < rhs.u : v < rhs.v;
}
} lt[M];

int ver[N], num[N];

int main () {
File();
while (cases --) {
For (i, 1, m) {
}
For (i, 1, n) {
num[ver[i]] = i;
}
if (m > 3 * n - 6) { puts("NO"); continue; }
For (i, 1, m) {
lt[i].u = num[lt[i].u];
lt[i].v = num[lt[i].v];
if (lt[i].u > lt[i].v) swap(lt[i].u, lt[i].v);
}
sort(lt + 1, lt + 1 + m);
T.Init(n);
For (i, 1, m) For (j, i + 1, m) {
if (lt[i].u == lt[i].v - 1 || (lt[i].u == 1 && lt[i].v == n)) continue ;
if (lt[i].u < lt[j].u && lt[j].u < lt[i].v && lt[i].v < lt[j].v) {