#include <bits/stdc++.h>
using namespace std;
int nod(int a, int b) {
  while (1) {
    a = a % b;
    if (a == 0) return b;
    b = b % a;
    if (b == 0) return a;
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  int a[102], b[102];
  for (int i = 0; i <= n; i++) cin >> a[i];
  for (int i = 0; i <= m; i++) cin >> b[i];
  if (n != m) {
    if (n > m) {
      if ((a[0] / abs(a[0])) * (b[0] / abs(b[0])) < 0)
        cout << "-Infinity";
      else
        cout << "Infinity";
      return 0;
    } else {
      cout << "0/1";
      return 0;
    }
  } else {
    int gcd = nod(abs(a[0]), abs(b[0]));
    cout << ((a[0] / abs(a[0])) * (b[0] / abs(b[0]))) * (abs(a[0]) / gcd) << "/"
         << (abs(b[0]) / gcd);
  }
  return 0;
}
