#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:65777216")
using namespace std;
const int N = 1511;
const int INF = 111111111;
const long long MOD = 1000000007;
const double eps = 1e-9;
const double pi = 3.14159265358979;
long long f[100][3001][2], ans;
int n, a[200], b[200], len;
int main() {
  scanf("%d%d", &n, &len);
  for (int i = 0; i < (n); i++) scanf("%d%d", &a[i], &b[i]);
  for (int i = 1; i <= (len); i++)
    for (int last = 0; last < (n); last++) {
      if (i - a[last] == 0) f[last][i][0] = 1;
      if (i - a[last] > 0)
        for (int prev = 0; prev < (n); prev++) {
          if (prev != last && b[prev] == a[last])
            f[last][i][0] += f[prev][i - a[last]][0];
          if (prev != last && a[prev] == a[last])
            f[last][i][0] += f[prev][i - a[last]][1];
        }
      if (a[last] != b[last]) {
        if (i - b[last] == 0) f[last][i][1] = 1;
        if (i - b[last] > 0)
          for (int prev = 0; prev < (n); prev++) {
            if (prev != last && b[prev] == b[last])
              f[last][i][1] += f[prev][i - b[last]][0];
            if (prev != last && a[prev] == b[last])
              f[last][i][1] += f[prev][i - b[last]][1];
          }
      }
      f[last][i][0] %= MOD;
      f[last][i][1] %= MOD;
    }
  for (int i = 0; i < (n); i++) ans += f[i][len][0] + f[i][len][1];
  printf("%d\n", ans % MOD);
  return 0;
}
