#include <bits/stdc++.h>
using namespace std;
int T, n, m, u, v, lab[300001];
vector<int> g[300001];
long long cnt[3];
long long const mod = 998244353;
bool impossible;
void DFS(const int& u) {
  for (const int& v : g[u])
    if (!lab[v]) {
      lab[v] = 3 - lab[u];
      cnt[lab[v]]++;
      DFS(v);
      if (impossible) return;
    } else if (lab[v] == lab[u]) {
      impossible = true;
      return;
    }
}
long long Pow(const long long& k) {
  if (k == 0) return 1;
  long long tmp = Pow(k / 2);
  if (k % 2 == 0)
    return tmp * tmp % mod;
  else
    return 2 * tmp * tmp % mod;
}
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++) {
      g[i].clear();
      lab[i] = 0;
    }
    while (m--) {
      scanf("%d%d", &u, &v);
      g[u].push_back(v);
      g[v].push_back(u);
    }
    long long res = 1;
    impossible = false;
    for (int i = 1; i <= n && !impossible; i++)
      if (!lab[i]) {
        lab[i] = 1;
        cnt[1] = 1;
        cnt[2] = 0;
        DFS(i);
        res = res * ((Pow(cnt[1]) + Pow(cnt[2])) % mod) % mod;
      }
    if (impossible)
      cout << 0 << "\n";
    else
      cout << res << "\n";
  }
}
