#include <bits/stdc++.h>
using namespace std;
int Id[2 * 105];
int L[2 * 105];
int W[2 * 105];
long long int dp[2 * 105][3005];
bool vis[2 * 105][3005];
int n, l;
long long int solve(int LastTp, int Len) {
  if (Len > l) return 0LL;
  if (Len == l) return 1LL;
  if (vis[LastTp][Len] == 1) return dp[LastTp][Len];
  vis[LastTp][Len] = 1;
  long long int ret = 0;
  for (int i = 1; i <= n; i++) {
    if (Id[i] == Id[LastTp]) continue;
    if (W[LastTp] == L[i]) ret = (ret + solve(i, Len + L[i])) % 1000000007;
  }
  return dp[LastTp][Len] = ret;
}
int main() {
  int N, x, y;
  scanf("%d %d", &N, &l);
  for (int i = 1; i <= N; i++) {
    scanf("%d %d", &x, &y);
    L[++n] = x;
    W[n] = y;
    Id[n] = i;
    if (x != y) {
      L[++n] = y;
      W[n] = x;
      Id[n] = i;
    }
  }
  long long int Sum = 0;
  for (int i = 1; i <= n; i++) Sum = (Sum + solve(i, L[i])) % 1000000007;
  cout << Sum << endl;
}
