#include <bits/stdc++.h>   using namespace std;   const int mx = 2e6 + 10;   int n, m;   bool vis[mx];   int sta[mx], siz, is;   int dfn[mx], id[mx];   int be[mx], ty;   vector<int> g[mx];   void tarjan(int u) {     dfn[u] = id[u] = ++is;     sta[++siz] = u;     vis[u] = 1;     for (int v : g[u]) {       if (!dfn[v]) {         tarjan(v);         id[u] = min(id[u], id[v]);       } else if (vis[v])         id[u] = min(id[u], dfn[v]);     }     if (id[u] == dfn[u]) {       ty++;       while (sta[siz] != u) {         be[sta[siz]] = ty;         vis[sta[siz]] = 0;         siz--;       }       be[u] = ty, vis[u] = 0, siz--;     }   }   int cnt_one() {     int cnt = 0;     for (int i = 1; i <= n; i++)       if (be[i] == 1) cnt++;     return cnt;   }   int main() {     int t;     scanf( %d , &t);     while (t--) {       scanf( %d%d , &n, &m);       for (int i = 1; i <= 2 * n; i++) g[i].clear();       ty = is = siz = 0;       for (int i = 1; i <= 2 * n; i++) dfn[i] = vis[i] = 0;       for (int i = 0, u, v; i < m; i++) {         scanf( %d%d , &u, &v);         if (u == v)           g[v + n].push_back(u);         else           g[u].push_back(v + n);       }       if (n == 1) {         puts( No );         continue;       }       for (int i = 1; i <= n; i++)         if (!dfn[i]) tarjan(i);       int cnt = cnt_one();       if (cnt == n)         puts( No );       else {         puts( Yes );         printf( %d %d n , cnt, n - cnt);         for (int i = 1; i <= n; i++)           if (be[i] == 1) printf( %d  , i);         puts(  );         for (int i = 1; i <= n; i++)           if (be[i] != 1) printf( %d  , i);         puts(  );       }     }     return 0;   }   