#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
long long ans;
long long n, l;
long long x[105];
long long y[105];
long long dp[105][105][3005];
long long solve(long long ind, long long w, long long len) {
  if (len > l) return 0LL;
  if (len == l) return 1LL;
  if (dp[ind][w][len] != -1) return dp[ind][w][len];
  long long res = 0LL;
  for (int i = 0; i < n; i++) {
    if (i == ind) continue;
    if (x[i] == w) res += solve(i, y[i], len + x[i]);
    res %= MOD;
    if (x[i] == y[i]) continue;
    if (y[i] == w) res += solve(i, x[i], len + y[i]);
    res %= MOD;
  }
  return dp[ind][w][len] = (res % MOD);
}
int main() {
  memset(dp, -1, sizeof dp);
  cin >> n >> l;
  for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
  for (int i = 0; i < n; i++) {
    ans += solve(i, x[i], y[i]);
    ans %= MOD;
    if (y[i] == x[i]) continue;
    ans += solve(i, y[i], x[i]);
    ans %= MOD;
  }
  ans %= MOD;
  cout << ans << endl;
  return 0;
}
