#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> v[100001];
vector<int> id[100001];
bool saw[100001];
bool used[100001];
int same[100001];
long long ans[2][2];
int ho = 0, ge = 1;
int hoho = 0, gege = 1;
long long dp[2][2][2][2];
void func(int x) {
  if (saw[x]) {
    long long ret[2];
    for (int i = 0; i < 2; i++) ret[i] = 0;
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 2; j++)
        for (int k = 0; k < 2; k++) {
          ret[j ^ (i | k)] += dp[i][gege][j][k];
        }
    ans[ho][0] = (ans[ge][0] * ret[0] + ans[ge][1] * ret[1]) % 1000000007;
    ans[ho][1] = (ans[ge][0] * ret[1] + ans[ge][1] * ret[0]) % 1000000007;
    swap(ho, ge);
    return;
  }
  saw[x] = true;
  if (v[x].size() == 1) {
    long long check = 0;
    long long ret[2];
    for (int i = 0; i < 2; i++) ret[i] = 0;
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 2; j++) check += dp[0][gege][i][j];
    if (check == 2) {
      if (same[v[x][0]]) {
        ans[ho][0] = (ans[ge][0] * 2) % 1000000007;
        ans[ho][1] = (ans[ge][1] * 2) % 1000000007;
      } else {
        ans[ho][0] = (ans[ge][1] * 2) % 1000000007;
        ans[ho][1] = (ans[ge][0] * 2) % 1000000007;
      }
      swap(ho, ge);
      return;
    }
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 2; j++) {
        ret[i ^ j] += dp[0][gege][i][j];
      }
    ans[ho][0] = (ans[ge][0] * ret[0] + ans[ge][1] * ret[1]) % 1000000007;
    ans[ho][1] = (ans[ge][0] * ret[1] + ans[ge][1] * ret[0]) % 1000000007;
    swap(ho, ge);
    return;
  }
  int vv;
  for (int i = 0; i < v[x].size(); i++) {
    if (used[v[x][i]]) continue;
    vv = v[x][i];
  }
  used[vv] = true;
  if (id[vv].size() == 1) {
    long long ret[2];
    for (int j = 0; j < 2; j++) ret[j] = 0;
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 2; j++)
        for (int k = 0; k < 2; k++) {
          ret[i ^ (j | k)] += dp[0][gege][i][j];
        }
    ans[ho][0] = (ans[ge][0] * ret[0] + ans[ge][1] * ret[1]) % 1000000007;
    ans[ho][1] = (ans[ge][0] * ret[1] + ans[ge][1] * ret[0]) % 1000000007;
    swap(ho, ge);
    return;
  }
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++)
      for (int k = 0; k < 2; k++) dp[i][hoho][j][k] = 0;
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < 2; k++) {
        for (int l = 0; l < 2; l++) {
          if (same[vv]) {
            dp[i][hoho][j ^ (k | l)][l] += dp[i][gege][j][k];
          } else {
            dp[i][hoho][j ^ (k | l)][l ^ 1] += dp[i][gege][j][k];
          }
        }
      }
    }
  }
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++)
      for (int k = 0; k < 2; k++) dp[i][hoho][j][k] %= 1000000007;
  swap(hoho, gege);
  for (int j = 0; j < id[vv].size(); j++) {
    if (id[vv][j] == x) continue;
    func(id[vv][j]);
  }
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) same[i] = 100000000;
  ans[ge][0] = 1;
  ans[ge][1] = 0;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    int a;
    for (int j = 0; j < x; j++) {
      scanf("%d", &a);
      if (same[abs(a)] == 100000000) {
        if (a > 0)
          same[abs(a)] = 2;
        else
          same[abs(a)] = -2;
      } else {
        if (same[abs(a)] * a > 0) {
          same[abs(a)] = 1;
        } else {
          same[abs(a)] = 0;
        }
      }
      v[i].push_back(abs(a));
      id[abs(a)].push_back(i);
    }
  }
  for (int i = 1; i <= m; i++) {
    if (id[i].size() == 0) {
      ans[ge][0] = (ans[ge][0] * 2) % 1000000007;
    }
  }
  for (int i = 0; i < n; i++) {
    if (v[i].size() > 1) continue;
    if (saw[i]) continue;
    used[v[i][0]] = true;
    saw[i] = true;
    if (id[v[i][0]].size() == 1) {
      ans[ho][0] = (ans[ge][0] + ans[ge][1]) % 1000000007;
      ans[ho][1] = (ans[ge][0] + ans[ge][1]) % 1000000007;
      swap(ho, ge);
      continue;
    }
    for (int j = 0; j < 2; j++)
      for (int k = 0; k < 2; k++)
        for (int l = 0; l < 2; l++)
          for (int u = 0; u < 2; u++) dp[j][k][l][u] = 0;
    dp[0][gege][1][same[v[i][0]]] = 1;
    dp[0][gege][0][!same[v[i][0]]] = 1;
    for (int j = 0; j < id[v[i][0]].size(); j++) {
      if (id[v[i][0]][j] == i) continue;
      func(id[v[i][0]][j]);
    }
  }
  for (int i = 0; i < n; i++) {
    if (saw[i]) continue;
    int ok = 0;
    for (int j = 0; j < v[i].size(); j++) {
      if (id[v[i][j]].size() != 2) {
        ok++;
      }
    }
    if (ok == 0) continue;
    used[v[i][0]] = true;
    used[v[i][1]] = true;
    if (ok == 2) {
      ans[ho][0] = (ans[ge][0] + ans[ge][1] * 3) % 1000000007;
      ans[ho][1] = (ans[ge][0] * 3 + ans[ge][1]) % 1000000007;
      swap(ho, ge);
      saw[i] = true;
      continue;
    }
    for (int j = 0; j < 2; j++)
      for (int k = 0; k < 2; k++)
        for (int l = 0; l < 2; l++) dp[j][gege][k][l] = 0;
    dp[0][gege][0][1] = 1;
    dp[0][gege][0][0] = 1;
    for (int j = 0; j < 2; j++) {
      if (id[v[i][j]].size() == 2) {
        used[v[i][j]] = false;
      }
    }
    func(i);
  }
  for (int i = 0; i < n; i++) {
    if (saw[i]) continue;
    for (int j = 0; j < id[v[i][0]].size(); j++) {
      if (id[v[i][0]][j] != i) {
        saw[id[v[i][0]][j]] = true;
      }
    }
    used[v[i][0]] = true;
    if (v[i][0] == v[i][1]) {
      if (same[v[i][0]]) {
        ans[ho][0] = (ans[ge][0] + ans[ge][1]) % 1000000007;
        ans[ho][1] = (ans[ge][0] + ans[ge][1]) % 1000000007;
      } else {
        ans[ho][0] = (ans[ge][1] * 2) % 1000000007;
        ans[ho][1] = (ans[ge][0] * 2) % 1000000007;
      }
      swap(ho, ge);
      continue;
    }
    for (int j = 0; j < 2; j++)
      for (int k = 0; k < 2; k++)
        for (int l = 0; l < 2; l++) dp[j][gege][k][l] = 0;
    dp[1][gege][0][same[v[i][0]]] = 1;
    dp[0][gege][0][!same[v[i][0]]] = 1;
    func(i);
  }
  cout << ans[ge][1] << endl;
}
