#include <bits/stdc++.h>
using namespace std;
long long max(long long a, long long b) {
  if (a > b) return a;
  return b;
}
long long min(long long a, long long b) {
  if (a < b) return a;
  return b;
}
const int MOD = 1e9 + 7, N = 102, L = 3005, INF = INT_MAX;
pair<long long, long long> a[N];
long long dp[L][N][2];
int main() {
  int n, l;
  cin >> n >> l;
  for (int i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second;
  }
  for (int i = 1; i <= l; i++) {
    for (int j = 0; j < n; j++) {
      if (a[j].first == i)
        dp[i][j][0] = 1;
      else if (a[j].first < i) {
        for (int c = 0; c < n; c++) {
          if (c == j) continue;
          if (a[c].second == a[j].first)
            dp[i][j][0] += dp[i - a[j].first][c][0];
          if (a[c].first == a[j].first && a[c].first != a[c].second)
            dp[i][j][0] += dp[i - a[j].first][c][1];
          dp[i][j][0] %= MOD;
        }
      }
      if (a[j].second == i)
        dp[i][j][1] = 1;
      else if (a[j].second < i) {
        for (int c = 0; c < n; c++) {
          if (c == j) continue;
          if (a[c].second == a[j].second)
            dp[i][j][1] += dp[i - a[j].second][c][0];
          if (a[c].first == a[j].second && a[c].first != a[c].second)
            dp[i][j][1] += dp[i - a[j].second][c][1];
          dp[i][j][1] %= MOD;
        }
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    ans += dp[l][i][0];
    if (a[i].first != a[i].second) ans += dp[l][i][1];
    ans %= MOD;
  }
  cout << ans << "\n";
  return 0;
}
