#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:56777216")
const long long MOD = 1000000007;
long long dp[100][3001][2];
int n, l;
int a[100], b[100];
long long Dp(int type, int i, int rotated) {
  int width = rotated ? b[type] : a[type];
  int height = rotated ? a[type] : b[type];
  if (width > i) return 0;
  long long& r = dp[type][i][rotated];
  if (r != -1) {
    return r;
  }
  r = 0;
  if (width == i) {
    r = 1;
    return r;
  }
  int j = i - width;
  for (int type2 = 0; type2 < n; type2++) {
    if (type == type2) continue;
    int lim = a[type2] == b[type2] ? 1 : 2;
    for (int rotated2 = 0; rotated2 < lim; rotated2++) {
      int width2 = rotated2 ? b[type2] : a[type2];
      if (j >= width2 && width2 == height) {
        r = (r + Dp(type2, j, rotated2)) % MOD;
      }
    }
  }
  return r;
}
int main() {
  scanf("%d%d", &n, &l);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &a[i], &b[i]);
  }
  memset(dp, -1, sizeof(dp));
  long long ans = 0;
  for (int type = 0; type < n; type++) {
    int lim = a[type] == b[type] ? 1 : 2;
    for (int rotated = 0; rotated < lim; rotated++) {
      ans = (ans + Dp(type, l, rotated)) % MOD;
    }
  }
  printf("%d\n", int(ans));
  return 0;
}
