#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000 * 1000 * 1000 + 7;
int n, len;
int arr[105][2];
int dp[3005][105][2];
inline int rec(int pos, int prev, int prevor) {
  if (pos == 0) return 1;
  int &ret = dp[pos][prev][prevor];
  if (ret != -1) return ret;
  ret = 0;
  for (int i = 1; i <= n; i++) {
    if (i == prev) continue;
    for (int j = 0; j < 2; j++) {
      if (arr[i][0] == arr[i][1] && j == 1) continue;
      if (pos >= arr[i][1 - j] && arr[i][j] == arr[prev][prevor]) {
        ret += rec(pos - arr[i][1 - j], i, 1 - j);
        ret %= MOD;
      }
    }
  }
  return ret;
}
int main() {
  memset(dp, -1, sizeof(dp));
  scanf("%d %d", &n, &len);
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 2; j++) {
      scanf("%d", &arr[i][j]);
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (len >= arr[i][0]) ans += rec(len - arr[i][0], i, 0);
    ans %= MOD;
    if (arr[i][0] != arr[i][1]) {
      if (len >= arr[i][1]) ans += rec(len - arr[i][1], i, 1);
      ans %= MOD;
    }
  }
  printf("%d\n", ans);
  return 0;
}
