#include <bits/stdc++.h>
int dr[] = {2, 2, -2, -2, 1, -1, 1, -1};
int dc[] = {1, -1, 1, -1, 2, 2, -2, -2};
int dr1[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dc1[] = {1, -1, 1, 0, -1, 0, 1, -1};
int dr2[] = {0, 0, 1, -1};
int dc2[] = {1, -1, 0, 0};
using namespace std;
long long int dp[104][3005][2], n;
long long int a[1045], b[1045];
long long int cal(long long int x, long long int y, long long int f) {
  long long int i;
  if (y < 0) return 0;
  if (y == 0) return 1;
  long long int &r = dp[x][y][f];
  if (r != -1) return r;
  r = 0;
  long long int l = a[x], w = b[x];
  if (f == 1) swap(l, w);
  for (i = 1; i <= n; i++) {
    if (i == x) continue;
    if (a[i] == w) r += cal(i, y - a[i], 0);
    r %= 1000000007;
    if (a[i] == b[i]) continue;
    if (b[i] == w) r += cal(i, y - b[i], 1);
    r %= 1000000007;
  }
  return r;
}
int main() {
  long long int m, i, j;
  while (cin >> n >> m) {
    for (i = 1; i <= n; i++) cin >> a[i] >> b[i];
    memset(dp, -1, sizeof(dp));
    long long int ans = 0;
    for (i = 1; i <= n; i++) {
      ans += cal(i, m - a[i], 0);
      ans %= 1000000007;
      if (a[i] == b[i]) continue;
      ans += cal(i, m - b[i], 1);
      ans %= 1000000007;
    }
    cout << ans << endl;
  }
  return 0;
}
