#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int maxn = 105;
int N, L;
int a[maxn];
int b[maxn];
long long dp[3005][maxn][2];
int main() {
  cin >> N >> L;
  for (int i = 0; i < N; ++i) {
    scanf("%d%d", &a[i], &b[i]);
  }
  for (int i = 0; i < N; ++i) {
    dp[a[i]][i][0] = 1;
    dp[b[i]][i][1] = 1;
  }
  for (int i = 1; i <= L; ++i) {
    for (int j = 0; j < N; ++j) {
      for (int k = 0; k < N; ++k) {
        if (k == j) continue;
        if (i >= a[j]) {
          if (a[j] == b[k]) {
            dp[i][j][0] += dp[i - a[j]][k][0];
          } else if (a[j] == a[k]) {
            dp[i][j][0] += dp[i - a[j]][k][1];
          }
        }
        if (i >= b[j]) {
          if (b[j] == b[k]) {
            dp[i][j][1] += dp[i - b[j]][k][0];
          } else if (b[j] == a[k]) {
            dp[i][j][1] += dp[i - b[j]][k][1];
          }
        }
      }
      dp[i][j][0] %= MOD;
      dp[i][j][1] %= MOD;
    }
  }
  long long ans = 0;
  for (int i = 0; i < N; ++i) {
    ans += dp[L][i][0];
    if (a[i] != b[i]) ans += dp[L][i][1];
  }
  ans %= MOD;
  cout << ans << endl;
  return 0;
}
