#include <bits/stdc++.h>
using namespace std;
int inf = 1000000007;
int f[300005][105][2];
struct point {
  int x, y;
} a[105];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) scanf("%d%d", &a[i].x, &a[i].y);
  for (int i = 1; i <= m; i++) {
    for (int j = 0; j < n; j++) {
      if (a[j].x == i)
        f[i][j][0] = 1;
      else {
        if (a[j].x < i)
          for (int k = 0; k < n; k++)
            if (k != j) {
              if (a[k].y == a[j].x)
                f[i][j][0] = (f[i][j][0] + f[i - a[j].x][k][0]) % inf;
              if (a[k].x == a[j].x)
                f[i][j][0] = (f[i][j][0] + f[i - a[j].x][k][1]) % inf;
            }
      }
      if (a[j].x != a[j].y) {
        if (a[j].y == i)
          f[i][j][1] = 1;
        else {
          if (a[j].y < i)
            for (int k = 0; k < n; k++)
              if (k != j) {
                if (a[k].y == a[j].y)
                  f[i][j][1] = (f[i][j][1] + f[i - a[j].y][k][0]) % inf;
                if (a[k].x == a[j].y)
                  f[i][j][1] = (f[i][j][1] + f[i - a[j].y][k][1]) % inf;
              }
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j <= 1; j++) ans = (ans + f[m][i][j]) % inf;
  cout << ans % inf;
  ans--;
  ans++;
}
