#include <bits/stdc++.h>
using namespace std;
int main() {
  int q, w, e, r, t = 0, c, *a[200], s[200], d[200], f[200], p = 1000000007;
  cin >> q >> w;
  for (e = 0; e < 200; e++) {
    a[e] = new int[3001];
    for (r = 0; r <= w; r++) a[e][r] = 0;
  }
  for (; q; q--) {
    cin >> e >> r;
    s[t] = e;
    d[t] = r;
    f[t] = q;
    a[t][r]++;
    t++;
    if (e != r) {
      s[t] = r;
      d[t] = e;
      f[t] = q;
      a[t][e]++;
      t++;
    }
  }
  for (r = 0; r < w; r++)
    for (e = 0; e < t; e++)
      for (c = 0; c < t; c++)
        if ((f[e] != f[c]) && ((d[e] == s[c]) && (r + d[c] <= w))) {
          a[c][r + d[c]] += a[e][r];
          if (a[c][r + d[c]] >= p) a[c][r + d[c]] -= p;
        }
  r = 0;
  for (e = 0; e < t; e++) {
    r += a[e][w];
    if (r >= p) r -= p;
  }
  cout << r;
  return 0;
}
