#include <bits/stdc++.h>
using namespace std;
using INT = long long;
int a[210], b[210], tp[210];
INT dp[210][3100];
int main() {
  int n, l;
  cin >> n >> l;
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &a[i], &b[i]);
    tp[i] = i;
  }
  int nn = n;
  for (int i = 1; i <= n; i++) {
    if (a[i] != b[i]) {
      tp[++nn] = i;
      a[nn] = b[i];
      b[nn] = a[i];
    }
  }
  for (int i = 1; i <= nn; i++) dp[i][a[i]] = 1;
  for (int d = 1; d < 3100; d++) {
    for (int i = 1; i <= nn; i++) {
      if (d <= a[i]) continue;
      for (int j = 1; j <= nn; j++) {
        if (tp[i] == tp[j]) continue;
        if (a[i] != b[j]) continue;
        if (!dp[j][d - a[i]]) continue;
        dp[i][d] = (dp[i][d] + dp[j][d - a[i]]) % 1000000007;
      }
    }
  }
  INT ans = 0;
  for (int i = 1; i <= nn; i++) ans = (ans + dp[i][l]) % 1000000007;
  ans = (ans + 1000000007) % 1000000007;
  cout << ans << endl;
  return 0;
}
