#include <bits/stdc++.h>
using namespace std;
int vis[300005];
vector<vector<int> > g;
int x = 0;
int y = 0;
bool dfs(int src) {
  bool c = 1;
  for (int i = 0; i < g[src].size(); i++) {
    if (!vis[g[src][i]]) {
      vis[g[src][i]] = -1 * vis[src];
      c &= dfs(g[src][i]);
      if (vis[src] == -1) {
        y++;
      } else {
        x++;
      }
    } else if (vis[src] == vis[g[src][i]]) {
      c &= 0;
    }
  }
  return c;
}
long long pow2[300009];
const long long mod = 998244353;
int main() {
  ios::sync_with_stdio(0);
  pow2[0] = 1;
  for (int i = 1; i < 300005; i++) {
    pow2[i] = (2 * pow2[i - 1] % 998244353) % 998244353;
  }
  int ii = 0;
  int T;
  cin >> T;
  while (T--) {
    int nbN, nbE;
    g.clear();
    cin >> nbN >> nbE;
    memset(vis, 0, sizeof(vis[0]) * (nbN + 2));
    g.resize(nbN + 1);
    for (int i = 0; i < nbE; i++) {
      int u, v;
      cin >> u >> v;
      g[u].push_back(v);
      g[v].push_back(u);
    }
    long long res = 1;
    bool b = 1;
    for (int i = 1; i <= nbN; i++) {
      if (!vis[i]) {
        x = 0;
        y = 1;
        vis[i] = 1;
        b = b & dfs(i);
        res = (res % mod * (pow2[x] % mod + pow2[y] % mod) % mod) % mod;
      }
    }
    int x = 0;
    int y = 0;
    if (b) {
      cout << res << endl;
    } else {
      cout << 0 << endl;
    }
  }
  return 0;
}
