#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 998244353;
long long int fpow(long long int a, long long int b) {
  if (b == 0) return 1;
  if (b == 1) return a;
  if (b % 2) return a * fpow(a, b - 1);
  long long int r = fpow(a, b / 2);
  return r * r % MOD;
}
bool color(vector<set<long long int> > &g, vector<bool> &v,
           unordered_map<long long int, long long int> &c, long long int i,
           long long int p = 0) {
  if (c[i]) return c[p] != c[i];
  v[i] = true;
  c[i] = (c[p] == 1 ? 2 : 1);
  bool ok = true;
  for (long long int child : g[i]) {
    if (child == p) continue;
    ok = ok && color(g, v, c, child, i);
  }
  return ok;
}
long long int bip(vector<set<long long int> > &g, vector<bool> &v,
                  long long int i) {
  long long int n = g.size() - 1, A = 0, B = 0;
  unordered_map<long long int, long long int> col;
  if (!color(g, v, col, i)) return 0;
  for (auto &c : col) {
    if (c.second == 1) A++;
    if (c.second == 2) B++;
  }
  return (fpow(2, A) + fpow(2, B)) % MOD;
}
long long int solve(vector<set<long long int> > &g) {
  long long int n = g.size() - 1, ans = 1;
  vector<bool> v(n + 1, false);
  for (long long int i = 1; i <= n; ++i) {
    if (v[i]) continue;
    ans = (ans * bip(g, v, i)) % MOD;
  }
  return ans;
}
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, m;
    cin >> n >> m;
    vector<set<long long int> > g(n + 1);
    while (m--) {
      long long int v1, v2;
      cin >> v1 >> v2;
      g[v1].insert(v2);
      g[v2].insert(v1);
    }
    cout << solve(g) << endl;
  }
  return 0;
}
