#include <bits/stdc++.h>
using namespace std;
long long dp[100010][220] = {0};
long long a[220], b[220];
int main() {
  int n, len;
  cin >> n >> len;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &a[i], &b[i]);
    dp[a[i]][i]++;
    if (a[i] != b[i]) {
      dp[b[i]][i + n]++;
      a[i + n] = b[i];
      b[i + n] = a[i];
    }
  }
  for (int i = 1; i <= len; i++) {
    for (int j = 1; j <= 2 * n; j++) {
      if (!dp[i][j]) continue;
      for (int k = 1; k <= 2 * n; k++) {
        if (j % n != k % n && b[j] == a[k]) {
          dp[i + a[k]][k] += dp[i][j];
          dp[i + a[k]][k] %= 1000000007;
        }
      }
    }
  }
  long long ans = 0;
  for (int i = 1; i <= 2 * n; i++) {
    (ans += dp[len][i]) %= 1000000007;
  }
  cout << ans << endl;
  return 0;
}
