#include <bits/stdc++.h>
using namespace std;
const long long inf = (1ll << 62) - 1;
const long long mod = 998244353;
const long long N = 2e5 + 10;
const long double pi = 3.14159265358979323846;
long long bPow(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) {
      res = (res * a) % mod;
    }
    b >>= 1;
    a = (a * a) % mod;
  }
  return res % mod;
}
long long gcd(long long a, long long b) {
  if (a < b) swap(a, b);
  if (b == 0) return a;
  return gcd(b, a % b);
}
vector<long long> fact(N, 0ll);
void factorial() {
  fact[0] = 1, fact[1] = 1;
  for (long long i = 2; i < N; i++) {
    fact[i] = (fact[i - 1] * i) % mod;
  }
}
long long ncr(long long n, long long r) {
  if (r > n) return 0;
  long long ans = fact[n] % mod;
  ans *= bPow(fact[r], mod - 2) % mod;
  ans %= mod;
  ans *= bPow(fact[n - r], mod - 2) % mod;
  ans %= mod;
  return ans;
}
vector<long long> primes(N, -1);
void sieve() {
  iota(primes.begin(), primes.end(), 0);
  for (long long i = 2; i * i <= N; ++i) {
    if (primes[i] == i) {
      for (long long j = 2 * i; j < N; j += i) {
        primes[j] = i;
      }
    }
  }
}
vector<vector<long long>> graph(N);
vector<bool> vis(N, false);
long long dfs(long long node, long long acid) {
  vis[node] = true;
  long long ans = 0;
  for (long long v : graph[node]) {
    if (v == acid or vis[v]) continue;
    ans += dfs(v, acid);
  }
  return 1 + ans;
}
void solve() {
  long long n, m, city1, city2;
  cin >> n >> m >> city1 >> city2;
  for (long long i = 0; i <= n + 1; ++i) {
    graph[i].clear();
    vis[i] = false;
  }
  for (long long i = 0; i < m; ++i) {
    long long u, v;
    cin >> u >> v;
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
  long long temp = dfs(city1, city2);
  long long a = n - temp - 1;
  for (long long i = 0; i <= n + 1; ++i) {
    vis[i] = false;
  }
  temp = dfs(city2, city1);
  long long b = n - temp - 1;
  cout << a * b << " \n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long tc = 1, test = 1;
  cin >> tc;
  while (tc--) {
    solve();
  }
}
