#include <bits/stdc++.h>   using namespace std;   const int maxn = 105000;   const int mod = 1e9 + 7;   vector<int> xloc[maxn], po[maxn];   vector<int> side[maxn], blk;   long long ans = 1;   long long c[maxn][2];   int vis[maxn], vis_cnt;   int d[maxn];   long long g[maxn][2][2];   long long f[maxn][2];   void dfs(int u, int id) {     if (vis[u]) return;     vis[u] = id;     blk.push_back(u);     for (int i = (0), iend = ((int)side[u].size() - 1); i <= iend; i++) {       int v = side[u][i];       if (vis[v]) continue;       dfs(v, id);     }   }   void dp(int id, int l1, int r1, int l2, int r2) {     for (int i = (0), iend = (blk.size() + 10); i <= iend; i++)       for (int j = (0), jend = (1); j <= jend; j++)         for (int k = (0), kend = (1); k <= kend; k++) g[i][j][k] = 0;     for (int i = (l1), iend = (r1); i <= iend; i++) g[0][0][i] = 1;     if ((!po[blk[0]][1]) || (abs(po[blk[0]][0]) == abs(po[blk[1]][0]) ||                              abs(po[blk[0]][0]) == abs(po[blk[1]][1])))       swap(po[blk[0]][0], po[blk[0]][1]);     for (int i = (1), iend = ((int)blk.size() - 1); i <= iend; i++)       if (abs(po[blk[i]][1]) == abs(po[blk[i - 1]][1]))         swap(po[blk[i]][0], po[blk[i]][1]);     for (int i = (1), iend = (blk.size()); i <= iend; i++) {       int x = blk[i - 1];       for (int j = (0), jend = (1); j <= jend; j++) {         for (int p = (0), pend = (1); p <= pend; p++) {           for (int q = (0), qend = (1); q <= qend; q++) {             g[i][((((po[x][0]) < 0) ^ p) | (((po[x][1]) < 0) ^ q)) ^ j][q] +=                 g[i - 1][j][p];             g[i][((((po[x][0]) < 0) ^ p) | (((po[x][1]) < 0) ^ q)) ^ j][q] %= mod;           }         }       }     }     for (int j = (0), jend = (1); j <= jend; j++) {       for (int k = (l2), kend = (r2); k <= kend; k++) {         c[id][j] += g[blk.size()][j][k];         c[id][j] %= mod;       }     }   }   int main() {     int n, m;     scanf( %d%d , &n, &m);     for (int i = (1), iend = (n); i <= iend; i++) {       int k, loc;       scanf( %d , &k);       while (k--) {         scanf( %d , &loc);         po[i].push_back(loc);         xloc[abs(loc)].push_back(i);       }     }     for (int i = (1), iend = (m); i <= iend; i++) {       if (xloc[i].size() == 2) {         side[xloc[i][0]].push_back(xloc[i][1]);         side[xloc[i][1]].push_back(xloc[i][0]);         d[xloc[i][0]]++;         d[xloc[i][1]]++;       } else if (!xloc[i].size())         ans *= 2, ans %= mod;     }     for (int i = (1), iend = (n); i <= iend; i++) {       if (vis[i]) continue;       blk.clear();       vis_cnt++;       dfs(i, vis_cnt);       if (blk.size() == 1) {         if (po[blk[0]].size() == 1)           c[vis_cnt][0] = 1, c[vis_cnt][1] = 1;         else if (abs(po[blk[0]][0]) != abs(po[blk[0]][1]))           c[vis_cnt][0] = 1, c[vis_cnt][1] = 3;         else if (po[blk[0]][0] == po[blk[0]][1])           c[vis_cnt][0] = 1, c[vis_cnt][1] = 1;         else           c[vis_cnt][0] = 0, c[vis_cnt][1] = 2;         continue;       }       int rt = 0;       for (int j = (0), jend = ((int)blk.size() - 1); j <= jend; j++) {         if (d[blk[j]] == 1) {           rt = blk[j];           break;         }       }       if (rt) {         for (int j = (0), jend = ((int)blk.size() - 1); j <= jend; j++)           vis[blk[j]] = 0;         blk.clear();         dfs(rt, vis_cnt);         int x = blk[0];         int l1 = 0, r1 = 1, l2 = 0, r2 = 1;         if (po[x].size() == 1) po[x].push_back(0), r1 = 0;         x = blk.back();         if (po[x].size() == 1) po[x].push_back(0), r2 = 0;         dp(vis_cnt, l1, r1, l2, r2);         continue;       }       dp(vis_cnt, 0, 0, 0, 0);       dp(vis_cnt, 1, 1, 1, 1);     }     f[0][0] = 1;     for (int i = (0), iend = (vis_cnt - 1); i <= iend; i++) {       for (int l = (0), lend = (1); l <= lend; l++) {         for (int x = (0), xend = (1); x <= xend; x++) {           f[i + 1][l ^ x] += f[i][l] * c[i + 1][x] % mod;           f[i + 1][l ^ x] %= mod;         }       }     }     printf( %lld , f[vis_cnt][1] * ans % mod);     return 0;   }