#include <bits/stdc++.h>
const int N = 1000010;
const int M = 2000010;
const int maxn = 60;
using namespace std;
int n, m;
int vis[N];
struct Graph {
  int edge[N], lst[N], nxt[N], t;
  void ADD(int x, int y) {
    edge[++t] = y;
    nxt[t] = lst[x];
    lst[x] = t;
  }
  void MEM() {
    for (int i = 1; i <= n; i++) lst[i] = 0;
    t = 0;
  }
  int SEARCH(int x) {
    vis[x] = 1;
    int res = 0;
    for (int r = lst[x]; r; r = nxt[r]) {
      if (!vis[edge[r]]) res += SEARCH(edge[r]);
    }
    return res + 1;
  }
  int CHK(int pd) {
    for (int i = 1; i <= n; i++) vis[i] = 0;
    int now = SEARCH(1);
    if (now == n) return 0;
    printf("Yes\n");
    if (pd == 0) {
      printf("%d %d\n", now, n - now);
      for (int i = 1; i <= n; i++)
        if (vis[i]) printf("%d ", i);
      puts("");
      for (int i = 1; i <= n; i++)
        if (!vis[i]) printf("%d ", i);
    } else {
      printf("%d %d\n", n - now, now);
      for (int i = 1; i <= n; i++)
        if (!vis[i]) printf("%d ", i);
      puts("");
      for (int i = 1; i <= n; i++)
        if (vis[i]) printf("%d ", i);
    }
    puts("");
    return 1;
  }
} gr[2];
void SOLVE() {
  int u, v;
  scanf("%d%d", &n, &m);
  for (int i = 0; i <= 1; i++) gr[i].MEM();
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &u, &v);
    if (u == v) continue;
    gr[0].ADD(u, v);
    gr[1].ADD(v, u);
  }
  for (int i = 0; i <= 1; i++) {
    if (gr[i].CHK(i)) return;
  }
  printf("No\n");
}
int main() {
  int T;
  scanf("%d", &T);
  while (T--) SOLVE();
  return 0;
}
