#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > M;
vector<int> widths;
vector<int> lengths;
vector<int> type;
int n;
int l;
vector<vector<int> > width;
vector<vector<int> > length;
int cnt;
int count() {
  for (int i = 0; i < n + cnt; ++i) {
    M[i][0] = 1;
  }
  for (int j = 1; j < l; ++j) {
    for (int i = 0; i < n + cnt; ++i) {
      int lastWidth = widths[i];
      M[i][j] = 0;
      for (int k = 0; lastWidth <= j and k < length[lastWidth].size(); ++k) {
        if (type[i] != type[length[lastWidth][k]])
          M[i][j] += M[length[lastWidth][k]][j - lastWidth];
        M[i][j] %= 1000000007;
      }
    }
  }
  int res = 0;
  for (int i = 0; i < n + cnt; ++i) {
    if (l >= lengths[i]) {
      res += M[i][l - lengths[i]];
      res %= 1000000007;
    }
  }
  return res;
}
int main() {
  cin >> n >> l;
  M = vector<vector<int> >(2 * n, vector<int>(l, -1));
  lengths = vector<int>(2 * n, 0);
  widths = vector<int>(2 * n, 0);
  type = vector<int>(2 * n, 0);
  length = vector<vector<int> >(101, vector<int>());
  cnt = 0;
  for (int i = 0; i < n; ++i) {
    int len, wid;
    cin >> len >> wid;
    lengths[i] = len;
    widths[i] = wid;
    length[len].push_back(i);
    type[i] = i;
    if (len != wid) {
      type[n + cnt] = i;
      swap(len, wid);
      lengths[n + cnt] = len;
      widths[n + cnt] = wid;
      length[len].push_back(n + cnt);
      ++cnt;
    }
  }
  cout << count() << endl;
}
