#include <bits/stdc++.h>
using namespace std;
const int V = 200;
int n, m;
int a[V], b[V];
int f[3200][V][2];
int mod(int x) { return x > 1000000007 ? x - 1000000007 : x; }
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d%d", &a[i], &b[i]);
  memset(f, 0, sizeof(f));
  for (int i = 0; i < n; i++) {
    f[a[i]][i][0] = 1;
    if (a[i] != b[i]) f[b[i]][i][1] = 1;
  }
  for (int i = 1; i <= m; i++)
    for (int j = 0; j < n; j++)
      for (int p = 0; p < 2; p++)
        if (f[i][j][p] > 0) {
          int next = (p == 0) ? b[j] : a[j];
          for (int k = 0; k < n; k++)
            if (k != j) {
              if (a[k] == next) {
                f[i + next][k][0] = mod(f[i + next][k][0] + f[i][j][p]);
              } else if (b[k] == next) {
                f[i + next][k][1] = mod(f[i + next][k][1] + f[i][j][p]);
              }
            }
        }
  int ans = 0;
  for (int j = 0; j < n; j++)
    for (int p = 0; p < 2; p++) ans = mod(ans + f[m][j][p]);
  printf("%d\n", ans);
}
