#include <bits/stdc++.h>
using namespace std;
long long int power(long long int a, long long int b) {
  if (b == 0) return 1;
  if (b == 1) return a;
  long long int c = power(a, b / 2);
  if (b % 2 == 0) return ((c % 998244353) * (c % 998244353)) % 998244353;
  return ((((c % 998244353) * (c % 998244353)) % 998244353) * (a % 998244353)) %
         998244353;
}
long long int visited[300005];
vector<long long int> v[300005];
long long int odd = 0;
long long int even = 0;
long long int flag = 0;
void func(long long int i, long long int type) {
  long long int j;
  visited[i] = type;
  if (type == 0)
    even++;
  else
    odd++;
  for (j = 0; j < v[i].size(); j++) {
    if (visited[v[i][j]] == -1)
      func(v[i][j], 1 - type);
    else if (visited[v[i][j]] == visited[i])
      flag = 1;
  }
}
int main() {
  long long int t, i, j;
  cin >> t;
  for (i = 0; i < t; i++) {
    long long int n, m1;
    cin >> n >> m1;
    for (j = 0; j < m1; j++) {
      long long int a, b;
      cin >> a >> b;
      v[a].push_back(b);
      v[b].push_back(a);
    }
    long long int ans = 1;
    for (j = 1; j <= n; j++) visited[j] = -1;
    for (j = 1; j <= n; j++) {
      if (visited[j] == -1) {
        odd = 0;
        even = 0;
        flag = 0;
        func(j, 0);
        if (flag == 1) ans = 0;
        ans =
            ((ans % 998244353) * (power(2, odd) + power(2, even))) % 998244353;
      }
    }
    cout << ans << endl;
    for (j = 1; j <= n; j++) {
      v[j].erase(v[j].begin(), v[j].end());
    }
    flag = 0;
  }
  return 0;
}
