#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int n, m;
struct pp {
  int id, flag, ip;
};
vector<pp> adj[101000];
int vis[101000], list[101000], dp[101000][2][2][2], ans[2], cnt,
    cont[2][101000];
bool vs[101000];
int main() {
  scanf("%d%d", &m, &n);
  int i, j, s, p, q, k, t, num, id[2], ip, pre;
  memset(vis, -1, sizeof(vis));
  cnt = 0;
  ans[0] = 1;
  ans[1] = 0;
  for (i = 0; i < m; i++) {
    scanf("%d", &num);
    for (j = 0; j < num; j++) scanf("%d", &id[j]);
    pp now;
    if (num == 2) {
      if (abs(id[0]) == abs(id[1])) {
        if (id[0] + id[1] == 0) {
          swap(ans[0], ans[1]);
          continue;
        }
      }
    }
    for (j = 0; j < num; j++) {
      vis[abs(id[j])] = 0;
      if (id[j] < 0) vis[abs(id[j])] = 1;
    }
    if (num == 2) {
      if (id[0] == id[1]) continue;
    } else if (num == 1) {
      if (id[0] < 0)
        cont[0][-id[0]]++;
      else
        cont[1][id[0]]++;
    }
    if (num == 2) {
      now.id = abs(id[1]);
      now.flag = 0;
      if (id[0] < 0) now.flag |= 1;
      if (id[1] < 0) now.flag |= 2;
      now.ip = cnt++;
      adj[abs(id[0])].push_back(now);
      now.id = abs(id[0]);
      now.flag = 0;
      if (id[1] < 0) now.flag |= 1;
      if (id[0] < 0) now.flag |= 2;
      adj[abs(id[1])].push_back(now);
    }
  }
  for (i = 1; i <= n; i++) {
    if (vs[i]) continue;
    if (vis[i] < 0) {
      vs[i] = true;
      ans[0] = (ans[0] << 1) % mod;
      ans[1] = (ans[1] << 1) % mod;
      continue;
    }
    if (adj[i].size() <= 1) {
      pre = -1;
      ip = i;
      if (adj[i].size() == 1) {
        for (s = 0; s < 2; s++)
          for (p = 0; p < 2; p++) dp[ip][0][s][p] = 0;
        dp[ip][0][0][0] = ans[0];
        dp[ip][0][0][1] = ans[1];
        if (cont[0][ip] % 2) swap(dp[ip][0][0][0], dp[ip][0][0][1]);
        dp[ip][0][1][0] = ans[0];
        dp[ip][0][1][1] = ans[1];
        if (cont[1][ip] % 2) swap(dp[ip][0][1][0], dp[ip][0][1][1]);
        while (true) {
          int ch = -1;
          vs[ip] = true;
          for (j = 0; j < adj[ip].size(); j++) {
            if (adj[ip][j].id != pre) break;
          }
          if (j >= adj[ip].size()) break;
          ch = adj[ip][j].id;
          for (s = 0; s < 2; s++)
            for (p = 0; p < 2; p++) dp[ch][0][s][p] = 0;
          for (s = 0; s < 2; s++)
            for (p = 0; p < 2; p++) {
              if (dp[ip][0][s][p] == 0) continue;
              for (q = 0; q < 2; q++) {
                int mv, ns = s ^ (adj[ip][j].flag & 1);
                if (adj[ip][j].flag & 2)
                  mv = ns | (q ^ 1);
                else
                  mv = ns | q;
                if ((cont[0][ch] % 2 && q == 0) || (cont[1][ch] % 2 && q == 1))
                  mv ^= 1;
                dp[ch][0][q][p ^ mv] =
                    (dp[ch][0][q][p ^ mv] + dp[ip][0][s][p]) % mod;
              }
            }
          pre = ip;
          ip = ch;
        }
        for (j = 0; j < 2; j++)
          ans[j] = (dp[ip][0][0][j] + dp[ip][0][1][j]) % mod;
      } else {
        vs[i] = true;
        int ts = (ans[0] + ans[1]) % mod;
        ans[0] = ans[1] = ts;
      }
    }
  }
  for (i = 1; i <= n; i++) {
    if (!vs[i]) {
      pre = -1;
      ip = i;
      for (j = 0; j < 2; j++)
        for (s = 0; s < 2; s++)
          for (p = 0; p < 2; p++) dp[ip][j][s][p] = 0;
      for (j = 0; j < 2; j++)
        for (s = 0; s < 2; s++) dp[ip][j][j][s] = ans[s];
      while (true) {
        int ch;
        vs[ip] = true;
        for (j = 0; j < adj[ip].size(); j++) {
          if (adj[ip][j].ip != pre) break;
        }
        ch = adj[ip][j].id;
        for (int jj = 0; jj < 2; jj++)
          for (s = 0; s < 2; s++)
            for (p = 0; p < 2; p++) dp[ch][jj][s][p] = 0;
        for (s = 0; s < 2; s++) {
          for (p = 0; p < 2; p++) {
            for (k = 0; k < 2; k++) {
              if (dp[ip][s][p][k] == 0) continue;
              for (q = 0; q < 2; q++) {
                if (ch == i && q != s) continue;
                int mv, np = p ^ (adj[ip][j].flag & 1);
                if (adj[ip][j].flag & 2)
                  mv = np | (q ^ 1);
                else
                  mv = np | q;
                dp[ch][s][q][k ^ mv] =
                    (dp[ch][s][q][k ^ mv] + dp[ip][s][p][k]) % mod;
              }
            }
          }
        }
        if (ch == i) break;
        pre = adj[ip][j].ip;
        ip = ch;
      }
      for (j = 0; j < 2; j++) ans[j] = (dp[i][0][0][j] + dp[i][1][1][j]) % mod;
    }
  }
  printf("%d\n", ans[1]);
  return 0;
}
