#include <bits/stdc++.h>
const int mod = 1000000007;
int n, l, a[110], b[110];
int i, j, k;
int ans[3010][110][2], out;
int main() {
  scanf("%d%d", &n, &l);
  for (i = 0; i < n; i++) scanf("%d%d", &a[i], &b[i]);
  memset(ans, 0, sizeof(ans));
  for (i = 0; i < n; i++) {
    ans[b[i]][i][0] = 1;
    if (a[i] != b[i]) ans[a[i]][i][1] = 1;
  }
  for (i = 1; i <= l; i++) {
    for (j = 0; j < n; j++) {
      for (k = 0; k < n; k++) {
        if (j == k) continue;
        if (a[k] == b[j]) {
          if (i >= b[j] + b[k]) {
            ans[i][j][0] += ans[i - b[j]][k][0];
            ans[i][j][0] %= mod;
          }
        }
        if (b[k] == b[j]) {
          if (i >= b[j] + a[k]) {
            ans[i][j][0] += ans[i - b[j]][k][1];
            ans[i][j][0] %= mod;
          }
        }
        if (a[j] == b[j]) continue;
        if (a[k] == a[j]) {
          if (i >= a[j] + b[k]) {
            ans[i][j][1] += ans[i - a[j]][k][0];
            ans[i][j][1] %= mod;
          }
        }
        if (b[k] == a[j]) {
          if (i >= a[j] + a[k]) {
            ans[i][j][1] += ans[i - a[j]][k][1];
            ans[i][j][1] %= mod;
          }
        }
      }
    }
  }
  out = 0;
  for (i = 0; i < n; i++)
    for (j = 0; j < 2; j++) out = (out + ans[l][i][j]) % mod;
  printf("%d\n", out);
  return 0;
}
