#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const int N = 230;
const int M = 3500;
int m, n;
int a[N], b[N];
long long dp[M][N];
int main() {
  cin >> m >> n;
  memset(dp, 0, sizeof(dp));
  for (int i = 0; i < m; ++i) {
    cin >> a[i] >> b[i];
    dp[a[i]][i]++;
    if (a[i] != b[i]) {
      a[i + m] = b[i];
      b[i + m] = a[i];
      dp[a[i + m]][i + m]++;
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < m * 2; ++j) {
      if (!dp[i][j]) continue;
      for (int k = 0; k < 2 * m; ++k) {
        if (j % m != k % m && a[k] == b[j])
          dp[i + a[k]][k] = (dp[i + a[k]][k] + dp[i][j]) % inf;
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < 2 * m; ++i) ans = (ans + dp[n][i]) % inf;
  cout << ans << endl;
  return 0;
}
