#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 500;
const int mo = 1e9 + 7;
void ntr(int &x) {
  if (x >= mo)
    x -= mo;
  else if (x < 0)
    x += mo;
}
void inc(int &x, int y) {
  x += y;
  ntr(x);
}
struct node {
  int to, f1, f2;
  node() {}
  node(int t1, int t2, int t3) { to = t1, f1 = t2, f2 = t3; }
};
vector<node> e[N];
int n, m, f[N][2][2][2], det[N][2], In[N];
bool vis[N];
void dfs(int t) {
  vis[t] = 1;
  bool fl = 1;
  for (int i = 0; i <= (int)e[t].size() - 1; i++)
    if (!vis[e[t][i].to]) {
      int to = e[t][i].to, x = e[t][i].f1, y = e[t][i].f2;
      dfs(to);
      for (int sp = 0; sp <= 1; sp++)
        for (int tp = 0; tp <= 1; tp++)
          for (int ep = 0; ep <= 1; ep++)
            for (int vl = 0; vl <= 1; vl++)
              inc(f[t][sp][ep][vl ^ ((sp ^ x) | (tp ^ y)) ^ det[t][sp]],
                  f[to][tp][ep][vl]);
      fl = 0;
    }
  if (fl) f[t][1][1][det[t][1]] = f[t][0][0][det[t][0]] = 1;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    int kd;
    scanf("%d", &kd);
    if (kd == 1) {
      int x;
      scanf("%d", &x);
      if (x < 0)
        det[-x][0] ^= 1;
      else
        det[x][1] ^= 1;
    }
    if (kd == 2) {
      int x, y;
      scanf("%d%d", &x, &y);
      int f1 = (x < 0), f2 = (y < 0);
      x = abs(x), y = abs(y);
      e[x].push_back(node(y, f1, f2));
      e[y].push_back(node(x, f2, f1));
      In[x]++, In[y]++;
    }
  }
  int ans[2] = {1, 0};
  for (int i = 1; i <= m; i++)
    if (In[i] < 2 && !vis[i]) {
      dfs(i);
      int tmp[2] = {ans[0], ans[1]};
      ans[0] = ans[1] = 0;
      for (int p1 = 0; p1 <= 1; p1++)
        for (int p2 = 0; p2 <= 1; p2++)
          for (int sp = 0; sp <= 1; sp++)
            for (int ep = 0; ep <= 1; ep++)
              inc(ans[p1 ^ p2], 1ll * tmp[p1] * f[i][sp][ep][p2] % mo);
    }
  for (int i = 1; i <= m; i++)
    if (!vis[i]) {
      dfs(i);
      int tmp[2] = {ans[0], ans[1]};
      ans[0] = ans[1] = 0;
      int x = e[i][1].f1, y = e[i][1].f2;
      for (int p1 = 0; p1 <= 1; p1++)
        for (int p2 = 0; p2 <= 1; p2++)
          for (int sp = 0; sp <= 1; sp++)
            for (int ep = 0; ep <= 1; ep++)
              inc(ans[p1 ^ p2 ^ ((sp ^ x) | (ep ^ y))],
                  1ll * tmp[p1] * f[i][sp][ep][p2] % mo);
    }
  printf("%d\n", ans[1]);
  return 0;
}
