#include <bits/stdc++.h>
using namespace std;
int an[101][100][3001], p[101][3001], md = 1e9 + 7;
vector<pair<pair<int, int>, int> > bl;
int main() {
  int n, l;
  scanf("%d%d", &n, &l);
  for (int i = 0; i < n; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    bl.push_back(make_pair(make_pair(a, b), i));
    if (a != b) bl.push_back(make_pair(make_pair(b, a), i));
  }
  for (int i = 0; i < bl.size(); ++i)
    an[bl[i].first.first][bl[i].second][bl[i].first.second] = 1,
    ++p[bl[i].first.first][bl[i].first.second];
  for (int i = 1; i < l; ++i)
    for (int j = 0; j < bl.size(); ++j) {
      int w = bl[j].first.first, l = bl[j].first.second, id = bl[j].second;
      if (i + l > 3000) continue;
      int z = p[l][i] - an[l][id][i];
      if (z >= md)
        z -= md;
      else if (z < 0)
        z += md;
      an[w][id][i + l] += z;
      if (an[w][id][i + l] >= md) an[w][id][i + l] -= md;
      p[w][i + l] += z;
      if (p[w][i + l] >= md) p[w][i + l] -= md;
    }
  int an = 0;
  for (int i = 0; i < 101; ++i) {
    an += p[i][l];
    if (an >= md) an -= md;
  }
  printf("%d\n", an);
}
