#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  vector<long long> a(n + 1);
  vector<long long> b(m + 1);
  for (long long i = 0; i <= n; i++) cin >> a[i];
  for (long long i = 0; i <= m; i++) cin >> b[i];
  if (n > m) {
    if ((a[0] > 0 && b[0] > 0) || (a[0] < 0 && b[0] < 0))
      cout << "Infinity"
           << "\n";
    else
      cout << "-Infinity"
           << "\n";
  } else if (m > n)
    cout << "0/1"
         << "\n";
  else {
    for (long long i = 2; i <= min(abs(a[0]), abs(b[0])); i++) {
      if (a[0] % i == 0 && b[0] % i == 0) {
        a[0] /= i;
        b[0] /= i;
        i--;
      }
    }
    if (a[0] < 0 && b[0] > 0 || a[0] > 0 && b[0] < 0) {
      cout << "-";
    }
    cout << abs(a[0]) << "/" << abs(b[0]);
  }
}
