#include <bits/stdc++.h>
using namespace std;
const int NN = 222, LEN = 3009, MOD = 1000000007;
bool v[NN][LEN];
int dp[NN][LEN];
bool dp_bool[NN][LEN];
bool v_bool[NN][LEN];
int n, org_len;
int type[NN];
struct node {
  int type, len, width;
  node(){};
};
node board[NN];
int rec(int pos, int len) {
  if (len == 0) return 1;
  if (v[pos][len] == true) return dp[pos][len];
  v[pos][len] = true;
  int &res = dp[pos][len];
  res = 0;
  for (int i = 0; i < n; i++)
    if (board[i].type != board[pos].type && board[i].len == board[pos].width) {
      if (i % 2 && board[i].len == board[i].width) continue;
      if (len - board[i].len >= 0) {
        res += rec(i, len - board[i].len);
        if (res >= MOD) res -= MOD;
      }
    }
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  scanf("%d%d", &n, &org_len);
  for (int i = 0; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    board[i * 2].type = i;
    board[i * 2].len = a;
    board[i * 2].width = b;
    board[i * 2 + 1].type = i;
    board[i * 2 + 1].len = b;
    board[i * 2 + 1].width = a;
  }
  n <<= 1;
  memset(v, 0, sizeof(v));
  int ans = 0;
  for (int i = 0; i < n; i++)
    if (org_len - board[i].len >= 0) {
      if (i % 2 && board[i].len == board[i].width) continue;
      ans += rec(i, org_len - board[i].len);
      if (ans >= MOD) ans -= MOD;
    }
  printf("%d\n", ans);
}
