#include <bits/stdc++.h>
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return (a / gcd(a, b) * b); }
unsigned long long power(unsigned long long a, unsigned long long b) {
  a %= 1000000007;
  unsigned long long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % 1000000007;
    a = a * a % 1000000007;
    b >>= 1;
  }
  return res % 1000000007;
}
long long modmul(long long x, long long y) { return (x * y) % 1000000007; }
long long modadd(long long x, long long y) { return (x + y) % 1000000007; }
long long modsub(long long x, long long y) {
  return (x - y + 1000000007) % 1000000007;
}
long long fact[1000007] = {0};
void facto() {
  fact[0] = 1;
  fact[1] = 1;
  for (long long i = 2; i < 100007; i++)
    fact[i] = (fact[i - 1] * i) % 1000000007;
}
long long ncr(long long n, long long r) {
  long long res = 1;
  res = fact[n];
  res = (res * (power(fact[r], 1000000007 - 2))) % 1000000007;
  res = (res * (power(fact[n - r], 1000000007 - 2))) % 1000000007;
  return res;
}
long long npr(long long n, long long r) {
  long long res = 1;
  res = fact[n];
  res = (res * (power(fact[n - r], 1000000007 - 2))) % 1000000007;
  return res;
}
bool prime[1000005];
using namespace std;
signed main() {
  long long n, m;
  cin >> n >> m;
  long long a[n + 1], 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) {
    long long l = a[0] / gcd(a[0], b[0]);
    long long m = b[0] / gcd(a[0], b[0]);
    if ((l > 0 && m > 0) || (l < 0 && m < 0))
      cout << abs(l) << "/" << abs(m) << endl;
    else
      cout << "-" << abs(l) << "/" << abs(m) << endl;
  } else if (n > m) {
    if ((a[0] > 0 && b[0] > 0) || (a[0] < 0 && b[0] < 0))
      cout << "Infinity" << endl;
    else
      cout << "-Infinity" << endl;
  } else
    cout << "0/1" << endl;
}
