#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 9;
int t, id, n, m, x, y, k, c, xx, yy, ans, p;
vector<pair<int, int>> v, adj[N];
bool fl, ok;
long long res, sum[N], cu[N];
char ch;
string s, z;
int L;
long long mem[103][3003][3];
pair<int, int> a[102];
long long dp(int last = n, int rem = L, int preL = 0) {
  if (rem < 0) return 0;
  if (!rem) return 1;
  long long& ret = mem[last][rem][preL];
  if (~ret) return ret;
  ret = 0;
  for (int i = 0; i < (int)n; ++i) {
    if (i == last) continue;
    if (!preL) {
      ret += dp(i, rem - a[i].first, 1), ret %= 1000000007;
      if (a[i].first == a[i].second) continue;
      ret += dp(i, rem - a[i].second, 2), ret %= 1000000007;
    }
    if (preL == 1) {
      if (a[i].first == a[last].second)
        ret += dp(i, rem - a[i].first, 1), ret %= 1000000007;
      if (a[i].first == a[i].second) continue;
      if (a[i].second == a[last].second)
        ret += dp(i, rem - a[i].second, 2), ret %= 1000000007;
    } else {
      if (a[i].first == a[last].first)
        ret += dp(i, rem - a[i].first, 1), ret %= 1000000007;
      if (a[i].first == a[i].second) continue;
      if (a[i].second == a[last].first)
        ret += dp(i, rem - a[i].second, 2), ret %= 1000000007;
    }
  }
  return ret;
}
int main() {
  memset(mem, -1, sizeof mem);
  ;
  scanf("%d%d", &n, &L);
  for (int i = 0; i < (int)n; ++i) scanf("%d%d", &a[i].first, &a[i].second);
  printf("%lld\n", dp());
  return 0;
}
