#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
const int MOD = 998244353;
vector<int> G[N];
int col[N];
int black, white;
long long pw[N];
void init() {
  pw[0] = 1;
  for (int i = 1; i <= 300000; i++) pw[i] = pw[i - 1] * 2 % MOD;
}
bool dfs(int u, int f, int c) {
  col[u] = c;
  ~c ? black++ : white++;
  for (auto v : G[u]) {
    if (v == f) continue;
    if (col[v] == c) return false;
    if (col[v] == 0 && !dfs(v, u, -c)) return false;
  }
  return true;
}
int main() {
  init();
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
      G[i].clear();
      col[i] = 0;
    }
    for (int i = 0; i < m; i++) {
      int u, v;
      cin >> u >> v;
      G[u].push_back(v);
      G[v].push_back(u);
    }
    long long ans = 1;
    bool f = true;
    for (int i = 1; i <= n; i++) {
      if (col[i] == 0) {
        black = white = 0;
        if (dfs(i, 0, 1)) {
          (ans *= pw[black] + pw[white]) %= MOD;
        } else {
          cout << 0 << endl;
          f = false;
          break;
        }
      }
    }
    if (f) cout << ans << endl;
  }
  return 0;
}
