#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, l;
  cin >> n >> l;
  unsigned long long d[l + 1][n][2];
  memset(d, 0, sizeof(d));
  vector<pair<int, int>> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i].first >> a[i].second;
  for (int i = 1; i <= l; ++i) {
    for (int j = 0; j < n; ++j) {
      if (i - a[j].first == 0) d[i][j][0]++;
      if (a[j].first != a[j].second && i - a[j].second == 0) d[i][j][1]++;
      for (int k = 0; k < n; ++k) {
        if (j == k) continue;
        if (a[j].first == a[k].first && i - a[j].first > 0)
          d[i][j][0] = (d[i][j][0] + d[i - a[j].first][k][1]) % 1000000007;
        if (a[j].first == a[k].second && i - a[j].first > 0)
          d[i][j][0] = (d[i][j][0] + d[i - a[j].first][k][0]) % 1000000007;
        if (a[j].first != a[j].second) {
          if (a[j].second == a[k].first && i - a[j].second > 0)
            d[i][j][1] = (d[i][j][1] + d[i - a[j].second][k][1]) % 1000000007;
          if (a[j].second == a[k].second && i - a[j].second > 0)
            d[i][j][1] = (d[i][j][1] + d[i - a[j].second][k][0]) % 1000000007;
        }
      }
    }
  }
  unsigned long long ans = 0;
  for (int i = 0; i < n; ++i)
    ans = ((ans + d[l][i][1]) % 1000000007 + d[l][i][0]) % 1000000007;
  cout << ans;
}
