#include <bits/stdc++.h>
using namespace std;
int a[111][2];
int dp[111][2][3004];
int main() {
  int N, L;
  cin >> N >> L;
  for (int i = 1; i <= N; i++) {
    cin >> a[i][0] >> a[i][1];
  }
  dp[0][0][0] = 1;
  int ans = 0;
  for (int l = 1; l <= L; l++) {
    for (int i = 1; i <= N; i++) {
      for (int t1 = 0; t1 < 2 - (a[i][0] == a[i][1]); t1++) {
        for (int j = 0; j <= N; j++) {
          if (i == j) continue;
          for (int t2 = 0; t2 < 2; t2++) {
            if (l < a[i][t1]) continue;
            if (!j || a[i][t1] == a[j][t2 ^ 1]) {
              dp[i][t1][l] += (dp[j][t2][l - a[i][t1]]);
              dp[i][t1][l] %= 1000000007;
            }
          }
        }
        if (l == L) {
          ans = (ans + dp[i][t1][l]) % 1000000007;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
