#include <bits/stdc++.h>
using namespace std;
const int maxn = 3000 + 100;
int dp[maxn][100 + 20][2];
int a[100 + 20], b[100 + 20];
const int mod = 1e9 + 7;
void MOD(int& x) { x %= mod; }
int main() {
  int n, l;
  while (scanf("%d %d", &n, &l) != EOF) {
    memset(dp, 0, sizeof(dp));
    for (int i = 1; i <= n; i++) {
      scanf("%d %d", &a[i], &b[i]);
      dp[a[i]][i][0] = 1;
      if (b[i] != a[i]) {
        dp[b[i]][i][1] = 1;
      }
    }
    for (int i = 1; i <= l; i++) {
      for (int j = 1; j <= n; j++) {
        if (a[j] <= i) {
          for (int k = 1; (k <= n); k++) {
            if (k == j) continue;
            if (a[j] == a[k]) {
              dp[i][j][0] += dp[i - a[j]][k][1];
              MOD(dp[i][j][0]);
            }
            if (a[j] == b[k]) {
              dp[i][j][0] += dp[i - a[j]][k][0];
              MOD(dp[i][j][0]);
            }
          }
        }
        if (b[j] <= i && b[j] != a[j]) {
          for (int k = 1; (k <= n); k++) {
            if (k == j) continue;
            if (b[j] == a[k]) {
              dp[i][j][1] += dp[i - b[j]][k][1];
              MOD(dp[i][j][1]);
            }
            if (b[j] == b[k]) {
              dp[i][j][1] += dp[i - b[j]][k][0];
              MOD(dp[i][j][1]);
            }
          }
        }
      }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
      ans += dp[l][i][0];
      MOD(ans);
      ans += dp[l][i][1];
      MOD(ans);
    }
    printf("%d\n", ans);
  }
  return 0;
}
