#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 7;
int t, n, m;
vector<int> E[2][maxn];
int vis[2][maxn], cnt = 0;
void dfs1(int x, int z) {
  vis[z][x] = 1;
  cnt++;
  for (int i = 0; i < E[z][x].size(); i++) {
    int v = E[z][x][i];
    if (vis[z][v]) continue;
    dfs1(v, z);
  }
}
void clear() {
  for (int i = 1; i <= n; i++) {
    vis[0][i] = vis[1][i] = 0;
    E[0][i].clear();
    E[1][i].clear();
  }
}
void solve() {
  scanf("%d%d", &n, &m);
  clear();
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    E[0][x].push_back(y);
    E[1][y].push_back(x);
  }
  for (int z = 0; z < 2; z++) {
    cnt = 0;
    dfs1(1, z);
    if (cnt < n) {
      puts("Yes");
      if (z == 0) {
        cout << cnt << " " << n - cnt << endl;
      } else {
        cout << n - cnt << " " << cnt << endl;
      }
      for (int i = 1; i <= n; i++) {
        if (vis[z][i] == 1 - z) cout << i << " ";
      }
      cout << endl;
      for (int i = 1; i <= n; i++) {
        if (vis[z][i] == z) cout << i << " ";
      }
      cout << endl;
      return;
    }
  }
  puts("No");
}
int main() {
  scanf("%d", &t);
  while (t--) solve();
  return 0;
}
