#include <bits/stdc++.h>
using namespace std;
const int N = 109, L = 3009, mod = 1e9 + 7;
int dp[L][N][N];
int n, l;
struct node {
  int x, y;
  void read() { scanf("%d%d", &x, &y); };
} a[N];
int dfs(int p, int fa, int w) {
  if (p > l) return 0;
  int &d = dp[p][fa][w];
  if (d + 1) return d;
  if (p == l) return d = 1;
  d = 0;
  for (int i = 1; i <= n; i++)
    if (i != fa) {
      if (a[i].x == w) d = (d + dfs(p + a[i].x, i, a[i].y)) % mod;
      if (a[i].x == a[i].y) continue;
      if (a[i].y == w) d = (d + dfs(p + a[i].y, i, a[i].x)) % mod;
    }
  return d;
}
int main() {
  cin >> n >> l;
  for (int i = 1; i <= n; i++) a[i].read();
  int ans = 0;
  memset(dp, -1, sizeof(dp));
  for (int i = 1; i <= 100; i++) {
    ans = (ans + dfs(0, 0, i)) % mod;
  }
  cout << ans;
  return 0;
}
