#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5, MOD = 998244353;
vector<int> adj[N];
int n, m, color[N], cc, c1, c2;
long long p2[N];
bool bfs_check(int u) {
  queue<int> q;
  q.push(u);
  color[u] = 1;
  while (!q.empty()) {
    int cur = q.front();
    cc++;
    if (color[cur] == 1)
      c1++;
    else
      c2++;
    q.pop();
    for (int v : adj[cur]) {
      if (color[v] == 0) {
        q.push(v);
        color[v] = 3 - color[cur];
      } else {
        if (color[v] != 3 - color[cur]) return false;
      }
    }
  }
  return true;
}
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  p2[0] = 1;
  for (int i = 1; i <= N; ++i) p2[i] = (1LL * (p2[i - 1] * 2)) % MOD;
  int nhi;
  cin >> nhi;
  while (nhi--) {
    memset(color, 0, sizeof(int) * (n + 5));
    cin >> n >> m;
    for (int i = 1; i <= m; ++i) {
      int u, v;
      cin >> u >> v;
      adj[u].push_back(v);
      adj[v].push_back(u);
    }
    long long res = 1;
    bool shit = false;
    for (int i = 1; i <= n; ++i)
      if (color[i] == 0) {
        cc = 0;
        c1 = c2 = 0;
        if (!bfs_check(i)) {
          cout << 0 << endl;
          shit = true;
          break;
        } else {
          long long a = (p2[c1] + p2[c2]) % MOD;
          res = (1LL * res * a) % MOD;
        }
      }
    if (!shit) {
      cout << res << endl;
    }
    for (int i = 1; i <= n; ++i) adj[i].clear();
  }
  return 0;
}
