#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long n, l, a[3001][101][2], ans;
pair<long long, long long> b[101];
int main() {
  long long i, j, k;
  cin >> n >> l;
  for (i = 1; i <= n; i++) {
    cin >> b[i].first >> b[i].second;
    if (b[i].second < b[i].first) swap(b[i].first, b[i].second);
    a[b[i].first][i][1]++;
    a[b[i].second][i][0]++;
  }
  for (i = 0; i <= l; i++) {
    for (j = 1; j <= n; j++) {
      for (k = 1; k <= n; k++) {
        if (k == j) continue;
        if (b[k].first == b[j].first) {
          if (i - b[j].first > 0)
            a[i][j][1] = (a[i][j][1] + a[i - b[j].first][k][0]) % mod;
        }
        if (b[k].second != b[k].first && b[k].second == b[j].first) {
          if (i - b[j].first > 0)
            a[i][j][1] = (a[i][j][1] + a[i - b[j].first][k][1]) % mod;
        }
        if (b[k].first == b[j].second) {
          if (i - b[j].second > 0)
            a[i][j][0] = (a[i][j][0] + a[i - b[j].second][k][0]) % mod;
        }
        if (b[k].second != b[k].first && b[k].second == b[j].second) {
          if (i - b[j].second > 0)
            a[i][j][0] = (a[i][j][0] + a[i - b[j].second][k][1]) % mod;
        }
      }
    }
  }
  for (i = 1; i <= n; i++) {
    ans = (ans + a[l][i][0]) % mod;
    if (b[i].first != b[i].second) ans = (ans + a[l][i][1]) % mod;
  }
  cout << ans << endl;
  return 0;
}
