#include <bits/stdc++.h>
using namespace std;
int vis[500007];
vector<int> graph[500007];
bool bipartite = true;
int x = 0, y = 0, bip = true;
void dfs(int node, int col) {
  if (col == -1)
    vis[node] = -1, x++;
  else
    vis[node] = -2, ++y;
  for (int i = 0; i < graph[node].size(); ++i) {
    if (vis[graph[node][i]] == vis[node])
      bip = false;
    else if (!vis[graph[node][i]] && bip) {
      dfs(graph[node][i], ((col == -1) * -2) + ((col == -2) * -1));
    }
  }
}
long long pow2[500007];
void pre_cal() {
  pow2[0] = 1;
  for (int i = 1; i < 500007; ++i)
    pow2[i] = 2 * pow2[i - 1], pow2[i] %= 998244353;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int test, n, m, a, b;
  pre_cal();
  cin >> test;
  while (test--) {
    cin >> n >> m;
    for (int i = 1; i <= m; ++i) {
      cin >> a >> b;
      graph[a].push_back(b);
      graph[b].push_back(a);
    }
    long long res = 1, curr = 0;
    for (int i = 1; i <= n; ++i) {
      if (!vis[i]) {
        curr = x = y = 0;
        bip = 1;
        dfs(i, -1);
        if (bip) {
          curr = (pow2[x] + pow2[y]) % 998244353;
          res *= curr;
          res %= 998244353;
        } else {
          res = 0;
          break;
        }
      }
    }
    cout << res << "\n";
    for (int i = 0; i <= n; ++i) {
      vis[i] = 0;
      while (graph[i].size()) graph[i].pop_back();
    }
  }
  return 0;
}
