#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i, j, a[110], b[110], a1, b1;
  cin >> n >> m;
  for (i = 0; i <= n; i++) cin >> a[i];
  for (i = 0; i <= m; i++) cin >> b[i];
  a1 = a[0], b1 = b[0];
  if (n > m) {
    if (a1 * b1 > 0)
      cout << "Infinity" << endl;
    else
      cout << "-Infinity" << endl;
  } else if (n < m) {
    printf("0/1\n");
  } else if (n == m) {
    for (i = 1; i <= min(abs(a1), abs(b1)); i++) {
      if (a1 % i == 0 && b1 % i == 0) j = i;
    }
    a1 /= j, b1 /= j;
    if (a1 * b1 > 0)
      printf("%d/%d\n", abs(a1), abs(b1));
    else
      printf("-%d/%d\n", abs(a1), abs(b1));
  }
  return 0;
}
