#include <bits/stdc++.h>
using namespace std;
const int MAX = 100 + 10;
const int MAXL = 3000 + 100;
const int INF = 1 << 29;
const long long D = 1000 * 1000 * 1000 + 7;
long long d[MAXL + 100][MAX + 10][2];
int f[MAX + 10][2];
bool mrk[MAX + 10];
int n, l;
void dyn() {
  for (int j = 0; j < n; j++)
    for (int k = 0; k < 1 + mrk[j]; k++) d[f[j][k]][j][k] = 1;
  for (int i = 0; i < l; i++)
    for (int j = 0; j < n; j++)
      for (int k = 0; k < 2; k++)
        for (int jj = 0; jj < n; jj++)
          for (int kk = 0; kk < 1 + mrk[jj]; kk++)
            if (j != jj && f[jj][kk] == f[j][1 - k]) {
              d[i + f[jj][kk]][jj][kk] += d[i][j][k];
              if (d[i + f[jj][kk]][jj][kk] > D) d[i + f[jj][kk]][jj][kk] -= D;
            }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> l;
  for (int i = 0; i < n; i++)
    cin >> f[i][0] >> f[i][1], mrk[i] = (f[i][0] != f[i][1]);
  dyn();
  long long sum = 0;
  for (int i = 0; i < n; i++) sum += d[l][i][0] + d[l][i][1];
  sum %= D;
  cout << sum << endl;
  return 0;
}
