#include <bits/stdc++.h>
using namespace std;
const int N = 1000100;
long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
vector<int> e1[N], e2[N];
int vis[N], cnt;
void dfs(int u) {
  vis[u] = 1;
  cnt++;
  for (vector<int>::iterator it = e1[u].begin(); it != e1[u].end(); ++it) {
    if (vis[*it]) continue;
    dfs(*it);
  }
}
void dfs2(int u) {
  vis[u] = 1;
  cnt++;
  for (vector<int>::iterator it = e2[u].begin(); it != e2[u].end(); ++it) {
    if (vis[*it]) continue;
    dfs2(*it);
  }
}
int main() {
  int T = read();
  while (T--) {
    int n = read(), m = read();
    cnt = 0;
    for (int i = 1; i <= n; ++i) vis[i] = 0;
    for (int i = 1; i <= n; ++i) e1[i].clear(), e2[i].clear();
    for (int i = 1; i <= m; ++i) {
      int u = read(), v = read();
      e1[u].push_back(v);
      e2[v].push_back(u);
    }
    dfs(1);
    int bz = 1;
    if (cnt == n) {
      cnt = 0;
      for (int i = 1; i <= n; ++i) vis[i] = 0;
      dfs2(1);
      if (cnt == n) {
        puts("No");
        continue;
      }
      cnt = n - cnt;
      bz = 0;
    }
    puts("Yes");
    printf("%d %d\n", cnt, n - cnt);
    for (int i = 1; i <= n; ++i) {
      if (vis[i] == bz) printf("%d ", i);
    }
    puts("");
    for (int i = 1; i <= n; ++i) {
      if (vis[i] != bz) printf("%d ", i);
    }
    puts("");
  }
  return 0;
}
