#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 5;
int n, m, gs, top, head[N], f[N];
struct node {
  int Next, too;
} edge[N * 2];
vector<int> A, B;
void add(int a, int b) {
  edge[++top].too = b;
  edge[top].Next = head[a];
  head[a] = top;
}
inline int read() {
  int ret = 0, f = 0;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = 1;
    c = getchar();
  }
  while (isdigit(c)) {
    ret = ret * 10 + c - 48;
    c = getchar();
  }
  if (f) return -ret;
  return ret;
}
void dfs(int u, int opt) {
  gs++;
  if (opt == 2) {
    for (int i = head[u]; i; i = edge[i].Next) {
      int v = edge[i].too;
      if (f[v]) continue;
      f[v] = 1;
      dfs(v, 1);
    }
  } else {
    if (u <= n) {
      if (!f[u + n]) {
        f[u + n] = 2;
        dfs(u + n, 2);
      }
    } else {
      if (!f[u - n]) {
        f[u - n] = 2;
        dfs(u - n, 2);
      }
    }
  }
}
signed main() {
  int T = read();
  while (T--) {
    A.clear();
    B.clear();
    top = 0;
    n = read();
    m = read();
    for (int i = 1; i <= 2 * n; i++) head[i] = 0;
    for (int i = 1; i <= m; i++) {
      int x = read(), y = read();
      add(x, y + n);
      add(y + n, x);
    }
    for (int i = 1; i <= 2 * n; i++) f[i] = 0;
    f[n + 1] = 2;
    gs = 0;
    dfs(n + 1, 2);
    if (gs != 2 * n) {
      for (int i = n + 1; i <= 2 * n; i++)
        if (f[i])
          B.push_back(i - n);
        else
          A.push_back(i - n);
      puts("Yes");
      printf("%d %d\n", A.size(), B.size());
      for (int i = 0; i < A.size(); i++) printf("%d ", A[i]);
      for (int i = 0; i < B.size(); i++) printf("%d ", B[i]);
      continue;
    }
    for (int i = 1; i <= 2 * n; i++) f[i] = 0;
    f[n + 1] = 1;
    gs = 0;
    dfs(n + 1, 1);
    if (gs != 2 * n) {
      for (int i = n + 1; i <= 2 * n; i++)
        if (f[i])
          A.push_back(i - n);
        else
          B.push_back(i - n);
      puts("Yes");
      printf("%d %d\n", A.size(), B.size());
      for (int i = 0; i < A.size(); i++) printf("%d ", A[i]);
      for (int i = 0; i < B.size(); i++) printf("%d ", B[i]);
      continue;
    }
    puts("No");
  }
}
