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