#include <bits/stdc++.h>
using namespace std;
int c[3001][100][2] = {0}, x[100], y[100], m = 0;
int main() {
  int n, l, i, j, k;
  cin >> n >> l;
  for (i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
    c[x[i]][i][0] = 1;
    c[y[i]][i][1] = 1;
  }
  for (i = 1; i <= l; i++)
    for (j = 0; j < n; j++)
      for (k = 0; k < n; k++)
        if (j != k) {
          if (i >= x[j] && x[j] == y[k])
            c[i][j][0] = (c[i][j][0] + c[i - x[j]][k][0]) % 1000000007;
          if (i >= x[j] && x[j] == x[k] && x[k] != y[k])
            c[i][j][0] = (c[i][j][0] + c[i - x[j]][k][1]) % 1000000007;
          if (i >= y[j] && y[j] == y[k])
            c[i][j][1] = (c[i][j][1] + c[i - y[j]][k][0]) % 1000000007;
          if (i >= y[j] && y[j] == x[k] && x[k] != y[k])
            c[i][j][1] = (c[i][j][1] + c[i - y[j]][k][1]) % 1000000007;
        }
  for (i = 0; i < n; i++) {
    m = (m + c[l][i][0]) % 1000000007;
    if (x[i] != y[i]) m = (m + c[l][i][1]) % 1000000007;
  }
  cout << m << endl;
  return 0;
}
