#include <bits/stdc++.h>
using namespace std;
const int MOD = (1e9) + 7;
int n, l, ans;
bool used[3128][128][2];
int state[3128][128][2];
int a[128], b[128];
int recurse(int length, int last, int flag) {
  if (length < 0) return 0;
  if (length == 0) return 1;
  if (used[length][last][flag]) return state[length][last][flag];
  int ans = 0, i, expected = ((flag == 1) ? a[last] : b[last]);
  for (i = 1; i <= n; i++)
    if (i != last) {
      if (a[i] == expected)
        ans = (ans + recurse(length - a[i], i, 0)) % MOD;
      else if (b[i] == expected)
        ans = (ans + recurse(length - b[i], i, 1)) % MOD;
    }
  used[length][last][flag] = true;
  state[length][last][flag] = ans;
  return ans;
}
int main() {
  int i;
  scanf("%d %d", &n, &l);
  for (i = 1; i <= n; i++) scanf("%d %d", &a[i], &b[i]);
  for (i = 1; i <= n; i++) {
    ans = (ans + recurse(l - a[i], i, 0)) % MOD;
    if (a[i] != b[i]) ans = (ans + recurse(l - b[i], i, 1)) % MOD;
  }
  printf("%d\n", ans);
  return 0;
}
