#include <bits/stdc++.h>
using namespace std;
const int Nmax = 1e6 + 7;
int n, m;
int pos;
char c;
struct TwoSat {
  static const int MAX_NODE = 2e6 + 7;
  vector<int> G[MAX_NODE];
  int n, sz;
  void clear() {
    for (int i = 0; i < n * 2; ++i) G[i].clear();
  }
  void init(int _n) {
    n = _n;
    for (int i = 0; i < n * 2; ++i) G[i].clear();
  }
  void addClause(int x, int xVal, int y, int yVal) {
    x = x * 2 + xVal, y = y * 2 + yVal;
    G[x ^ 1].push_back(y);
    G[y ^ 1].push_back(x);
  }
  void add(int x, int xVal, int y, int yVal) {
    x = x * 2 + xVal, y = y * 2 + yVal;
    G[x].push_back(y);
  }
  int book[MAX_NODE];
  inline void dfs(int now) {
    book[now] = 1;
    for (auto u : G[now]) {
      if (!book[u ^ 1]) dfs(u ^ 1);
    }
  }
  bool solve(int &j, int &p, int &isp) {
    for (int i = 0; i < n * 2; i++) book[i] = 0;
    dfs(0);
    int ans = 0;
    for (int i = 0; i < n * 2; i += 2) {
      if (book[i]) ans++;
    }
    if (ans != n) {
      j = ans;
      p = n - j;
      isp = 0;
      return 1;
    }
    for (int i = 0; i < n * 2; i++) book[i] = 0;
    dfs(1);
    ans = 0;
    for (int i = 1; i < n * 2; i += 2) {
      if (book[i]) ans++;
    }
    if (ans != n) {
      p = ans;
      j = n - p;
      isp = 1;
      return 1;
    }
    return 0;
  }
} sat;
int pos1, pos2, pos3;
char c1, c2, c3;
bool b1, b2, b3;
vector<int> j, p;
int main() {
  int t;
  scanf("%d", &t);
  while (~scanf("%d%d", &n, &m)) {
    sat.init(n);
    for (int i = 1; i <= m; i++) {
      int x, y;
      scanf("%d%d", &x, &y);
      x--, y--;
      sat.add(x, 0, y, 1);
      sat.add(y, 1, x, 0);
    }
    j.clear();
    p.clear();
    int x, y;
    int is;
    if (sat.solve(x, y, is)) {
      printf("Yes\n");
      for (int i = 0; i < n; i++) {
        if (is) {
          if (sat.book[2 * i + 1])
            p.push_back(i + 1);
          else
            j.push_back(i + 1);
        } else {
          if (sat.book[2 * i])
            j.push_back(i + 1);
          else
            p.push_back(i + 1);
        }
      }
      printf("%d %d\n", (int)j.size(), (int)p.size());
      for (auto c : j) cout << c << " ";
      cout << endl;
      for (auto c : p) cout << c << " ";
      cout << endl;
    } else
      printf("No\n");
  }
  return 0;
}
