#include <bits/stdc++.h>
using namespace std;
class square {
 public:
  int a, b;
  square(int _a = 0, int _b = 0) {
    a = _a;
    b = _b;
  }
};
bool d[201][201];
int a[3001][201];
vector<square> v1;
int use[201];
int main() {
  int n, q, h, f;
  scanf("%d%d", &n, &q);
  for (int gh = 0, i = 0; i < n; i++) {
    scanf("%d%d", &h, &f);
    v1.push_back(square(h, f));
    use[gh] = i;
    if (h != f) v1.push_back(square(f, h)), use[++gh] = i;
    gh++;
  }
  n = v1.size();
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++)
      if (use[i] != use[j])
        if (v1[i].b == v1[j].a) d[i][j] = 1;
  }
  for (int i = 0; i < n; i++) a[v1[i].a][i] = 1;
  for (int l = 1; l <= q; l++)
    for (int p1 = 0; p1 < n; p1++)
      for (int p2 = 0; p2 < n; p2++) {
        if (l - v1[p1].a >= 0)
          a[l][p1] = a[l][p1] + a[l - v1[p1].a][p2] * d[p2][p1],
          a[l][p1] %= 1000000007;
      }
  long long int value = 0;
  for (int p1 = 0; p1 < n; p1++) value += a[q][p1], value %= 1000000007;
  printf("%d\n", value);
  return 0;
}
