#include <bits/stdc++.h>
using namespace std;
const int base = 1e9 + 7;
const int N = 2e5;
int f[N][4][4][2];
vector<int> ed[N], lst[N];
int a[N][4];
int v, cnt, cycled;
int n, m, kl1;
int g[N][2];
int ng[N][2];
int mar[N];
int b[N];
int us[N], zn[N];
int touched[N];
int mabs(int x) {
  if (x < 0)
    return -x;
  else
    return x;
}
void dfs(int x, int y) {
  v++;
  b[v] = x;
  for (int j = 1; j <= a[x][0]; j++) touched[mabs(a[x][j])] = 1;
  mar[x] = 1;
  for (int i = 0; i < ed[x].size(); i++) {
    int to = ed[x][i];
    if (mar[to] == 0)
      dfs(to, x);
    else if (to != y)
      cycled = 1;
  }
}
void add(int &x, int y) {
  x += y;
  if (x >= base) x -= base;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> m >> n;
  for (int i = 1; i <= m; i++) {
    cin >> a[i][0];
    for (int j = 1; j <= a[i][0]; j++) {
      cin >> a[i][j];
      int d = mabs(a[i][j]);
      lst[d].push_back(i);
    }
  }
  for (int i = 1; i <= n; i++) {
    if (lst[i].size() == 1) continue;
    if (lst[i].size() == 2 && lst[i][0] != lst[i][1]) {
      ed[lst[i][0]].push_back(lst[i][1]);
      ed[lst[i][1]].push_back(lst[i][0]);
    }
  }
  for (int ii = 1; ii <= m; ii++)
    if (mar[ii] == 0 && ed[ii].size() <= 1) {
      cycled = 0;
      v = 0;
      dfs(ii, 0);
      for (int i = 1; i <= v; i++)
        for (int j = 0; j <= 3; j++)
          for (int k = 0; k <= 3; k++)
            for (int xr = 0; xr <= 1; xr++) f[i][j][k][xr] = 0;
      for (int j = 0; j < (1 << a[b[1]][0]); j++) {
        cnt++;
        int x = b[1];
        int result = 0;
        int gd = 1;
        for (int e = 1; e <= a[x][0]; e++) {
          int bt = (j & (1 << (e - 1)));
          if (bt != 0) bt = 1;
          if (us[mabs(a[x][e])] != cnt) {
            us[mabs(a[x][e])] = cnt;
            zn[mabs(a[x][e])] = bt;
          } else if (zn[mabs(a[x][e])] != bt)
            gd = 0;
          if (a[x][e] > 0)
            result |= bt;
          else
            result |= (1 - bt);
        }
        f[1][j][j][result] = gd;
      }
      for (int i = 1; i < v; i++)
        for (int j = 0; j <= 3; j++)
          for (int k = 0; k <= 3; k++)
            for (int xr = 0; xr <= 1; xr++) {
              if (f[i][j][k][xr] == 0) continue;
              for (int nm = 0; nm < (1 << a[b[i + 1]][0]); nm++) {
                cnt++;
                int x = b[i];
                for (int e = 1; e <= a[x][0]; e++) {
                  int bt = (j & (1 << (e - 1)));
                  if (bt != 0) bt = 1;
                  if (us[mabs(a[x][e])] != cnt) {
                    us[mabs(a[x][e])] = cnt;
                    zn[mabs(a[x][e])] = bt;
                  } else if (zn[mabs(a[x][e])] != bt)
                    exit(1);
                }
                if (i + 1 == v && cycled == 1) {
                  int x = b[1];
                  for (int e = 1; e <= a[x][0]; e++) {
                    int bt = (k & (1 << (e - 1)));
                    if (bt != 0) bt = 1;
                    if (us[mabs(a[x][e])] != cnt) {
                      us[mabs(a[x][e])] = cnt;
                      zn[mabs(a[x][e])] = bt;
                    } else if (zn[mabs(a[x][e])] != bt)
                      exit(1);
                  }
                }
                x = b[i + 1];
                int result = 0;
                int gd = 1;
                for (int e = 1; e <= a[x][0]; e++) {
                  int bt = (nm & (1 << (e - 1)));
                  if (bt != 0) bt = 1;
                  if (us[mabs(a[x][e])] != cnt) {
                    us[mabs(a[x][e])] = cnt;
                    zn[mabs(a[x][e])] = bt;
                  } else if (zn[mabs(a[x][e])] != bt)
                    gd = 0;
                  if (a[x][e] > 0)
                    result |= bt;
                  else
                    result |= (1 - bt);
                }
                if (gd == 1) add(f[i + 1][nm][k][xr ^ result], f[i][j][k][xr]);
              }
            }
      kl1++;
      for (int j = 0; j <= 3; j++)
        for (int k = 0; k <= 3; k++)
          for (int xr = 0; xr <= 1; xr++) add(g[kl1][xr], f[v][j][k][xr]);
    }
  for (int ii = 1; ii <= m; ii++)
    if (mar[ii] == 0 && ed[ii].size() <= 2) {
      cycled = 0;
      v = 0;
      dfs(ii, 0);
      for (int i = 1; i <= v; i++)
        for (int j = 0; j <= 3; j++)
          for (int k = 0; k <= 3; k++)
            for (int xr = 0; xr <= 1; xr++) f[i][j][k][xr] = 0;
      for (int j = 0; j < (1 << a[b[1]][0]); j++) {
        cnt++;
        int x = b[1];
        int result = 0;
        int gd = 1;
        for (int e = 1; e <= a[x][0]; e++) {
          int bt = (j & (1 << (e - 1)));
          if (bt != 0) bt = 1;
          if (us[mabs(a[x][e])] != cnt) {
            us[mabs(a[x][e])] = cnt;
            zn[mabs(a[x][e])] = bt;
          } else if (zn[mabs(a[x][e])] != bt)
            gd = 0;
          if (a[x][e] > 0)
            result |= bt;
          else
            result |= (1 - bt);
        }
        f[1][j][j][result] = gd;
      }
      for (int i = 1; i < v; i++)
        for (int j = 0; j <= 3; j++)
          for (int k = 0; k <= 3; k++)
            for (int xr = 0; xr <= 1; xr++) {
              if (f[i][j][k][xr] == 0) continue;
              for (int nm = 0; nm < (1 << a[b[i + 1]][0]); nm++) {
                cnt++;
                int x = b[i];
                for (int e = 1; e <= a[x][0]; e++) {
                  int bt = (j & (1 << (e - 1)));
                  if (bt != 0) bt = 1;
                  if (us[mabs(a[x][e])] != cnt) {
                    us[mabs(a[x][e])] = cnt;
                    zn[mabs(a[x][e])] = bt;
                  } else if (zn[mabs(a[x][e])] != bt)
                    exit(1);
                }
                if (i + 1 == v && cycled == 1) {
                  int x = b[1];
                  for (int e = 1; e <= a[x][0]; e++) {
                    int bt = (k & (1 << (e - 1)));
                    if (bt != 0) bt = 1;
                    if (us[mabs(a[x][e])] != cnt) {
                      us[mabs(a[x][e])] = cnt;
                      zn[mabs(a[x][e])] = bt;
                    } else if (zn[mabs(a[x][e])] != bt)
                      exit(1);
                  }
                }
                x = b[i + 1];
                int result = 0;
                int gd = 1;
                for (int e = 1; e <= a[x][0]; e++) {
                  int bt = (nm & (1 << (e - 1)));
                  if (bt != 0) bt = 1;
                  if (us[mabs(a[x][e])] != cnt) {
                    us[mabs(a[x][e])] = cnt;
                    zn[mabs(a[x][e])] = bt;
                  } else if (zn[mabs(a[x][e])] != bt)
                    gd = 0;
                  if (a[x][e] > 0)
                    result |= bt;
                  else
                    result |= (1 - bt);
                }
                if (gd == 1) add(f[i + 1][nm][k][xr ^ result], f[i][j][k][xr]);
              }
            }
      kl1++;
      for (int j = 0; j <= 3; j++)
        for (int k = 0; k <= 3; k++)
          for (int xr = 0; xr <= 1; xr++) add(g[kl1][xr], f[v][j][k][xr]);
    }
  ng[1][0] = g[1][0];
  ng[1][1] = g[1][1];
  for (int i = 1; i < kl1; i++) {
    for (int j = 0; j <= 1; j++)
      for (int k = 0; k <= 1; k++)
        add(ng[i + 1][j ^ k], 1ll * ng[i][j] * g[i + 1][k] % base);
  }
  for (int i = 1; i <= n; i++)
    if (touched[i] == 0) add(ng[kl1][1], ng[kl1][1]);
  cout << ng[kl1][1] << "\n";
}
