#include <bits/stdc++.h>
using namespace std;
long long inf = 1e18;
long long mod = 1e9 + 7;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m;
  cin >> n >> m;
  vector<long long> arr(n + 1);
  vector<long long> brr(m + 1);
  for (long long i = 0; i < n + 1; i++) cin >> arr[i];
  for (long long i = 0; i < m + 1; i++) cin >> brr[i];
  if (n < m) {
    cout << "0/1";
  } else if (n > m) {
    if (arr[0] * brr[0] < 0) cout << "-";
    cout << "Infinity";
  } else {
    if (arr[0] * brr[0] < 0) cout << "-";
    if (arr[0] < 0) {
      arr[0] = -arr[0];
    }
    if (brr[0] < 0) {
      brr[0] = -brr[0];
    }
    cout << arr[0] / gcd(arr[0], brr[0]) << "/" << brr[0] / gcd(arr[0], brr[0]);
  }
  return 0;
}
