#include <bits/stdc++.h>
using namespace std;
vector<long long> adj[300006];
int col[300007];
string s;
long long MD = 998244353;
long long res0 = 1, res1 = 1, res;
bool fl = 0;
void dfs(int u) {
  if (adj[u].size() == 0) return;
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i];
    if (col[v] == -1) {
      col[v] = 1 - col[u];
      if (col[v] == 0) {
        res0 *= 2;
        if (res0 >= MD) res0 %= MD;
      } else {
        res1 *= 2;
        if (res1 >= MD) res1 %= MD;
      }
      dfs(v);
    } else {
      if (col[u] == col[v]) {
        fl = 1;
        return;
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long t, n, e, u, v;
  cin >> t;
  while (t--) {
    res = 1;
    fl = 0;
    cin >> n >> e;
    for (int tt = 1; tt <= n; tt++) adj[tt].clear();
    for (int i = 1; i <= n; i++) col[i] = -1;
    for (int i = 0; i < e; i++) {
      cin >> u >> v;
      adj[u].push_back(v);
      adj[v].push_back(u);
    }
    for (int i = 1; i <= n; i++) {
      if (col[i] == -1) {
        col[i] = 0;
        res0 = 2, res1 = 1;
        dfs(i);
        res = (res * (res0 + res1) % MD) % MD;
      }
    }
    if (fl == 1)
      cout << 0 << endl;
    else
      cout << res << endl;
  }
  return 0;
}
