#include <bits/stdc++.h>
using namespace std;
const long long int M = 998244353;
long long int power(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res % p;
}
long long int modinver(long long int a, long long int b) {
  return (power(a, 1, M) * power(b, M - 2, M)) % M;
}
void SieveOfEratosthenes(int n) {
  bool prime[10005];
  memset(prime, true, sizeof(prime));
  for (int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
}
std::vector<long long int> v[300002];
long long int visited[300002];
long long int oddev[300002];
long long int odd = 0, even = 0;
long long int flag = 0;
void dfs(long long int x, long long int ty) {
  visited[x] = 1;
  oddev[x] = ty;
  if (ty == 0)
    even++;
  else
    odd++;
  for (int i = 0; i < v[x].size(); ++i) {
    if (visited[v[x][i]] == 0) {
      dfs(v[x][i], 1 - ty);
    } else {
      if (oddev[v[x][i]] == oddev[x]) flag = 1;
    }
  }
}
long long int a[300002], b[300002];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, m;
    cin >> n >> m;
    for (int i = 0; i <= n; ++i) {
      v[i].clear();
      visited[i] = 0;
      oddev[i] = -1;
    }
    for (int i = 0; i < m; ++i) {
      cin >> a[i] >> b[i];
      v[a[i]].push_back(b[i]);
      v[b[i]].push_back(a[i]);
    }
    long long int ans = 1;
    flag = 0;
    for (int i = 1; i <= n; ++i) {
      if (visited[i] == 0) {
        dfs(i, 0);
        ans = (ans % M * (power(2, odd, M) + power(2, even, M)) % M) % M;
        odd = 0;
        even = 0;
      }
    }
    if (flag) {
      cout << "0\n";
      continue;
    }
    cout << ans % M << '\n';
  }
}
