#include <bits/stdc++.h>
using namespace std;
const int N = 110, M = 3010, mod = 1e9 + 7;
int f[M][N][2], a[N], b[N];
int main() {
  int n, m, ans = 0;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d%d", &a[i], &b[i]);
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) {
      if (i == a[j]) f[i][j][0] = 1;
      if (a[j] != b[j] && i == b[j]) f[i][j][1] = 1;
      for (int k = 1; k <= n; k++) {
        if (j == k) continue;
        if (i >= a[j] && a[j] == a[k] && a[k] != b[k])
          f[i][j][0] = (f[i][j][0] + f[i - a[j]][k][1]) % mod;
        if (i >= a[j] && a[j] == b[k])
          f[i][j][0] = (f[i][j][0] + f[i - a[j]][k][0]) % mod;
        if (i < b[j] || a[j] == b[j]) continue;
        if (b[j] == a[k] && a[k] != b[k])
          f[i][j][1] = (f[i][j][1] + f[i - b[j]][k][1]) % mod;
        if (b[j] == b[k]) f[i][j][1] = (f[i][j][1] + f[i - b[j]][k][0]) % mod;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    ans = (ans + f[m][i][0]) % mod;
    if (a[i] != b[i]) ans = (ans + f[m][i][1]) % mod;
  }
  printf("%d\n", ans);
  return 0;
}
