#include <bits/stdc++.h>
using namespace std;
long long int M = 1000000007;
long long int gcd(long long int a, long long int b) {
  return (b == 0) ? a : gcd(b, a % b);
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t = 1;
  while (t--) {
    long long int m, n;
    cin >> m >> n;
    long long int a[m + 1], b[n + 1];
    for (long long int i = 0; i < m + 1; i++) cin >> a[i];
    for (long long int i = 0; i < n + 1; i++) cin >> b[i];
    if (m > n) {
      if ((a[0] > 0 && b[0] > 0) || (a[0] < 0 && b[0] < 0))
        cout << "Infinity";
      else
        cout << "-Infinity";
    } else if (m < n) {
      cout << "0/1"
           << "\n";
    } else {
      long long int num = a[0];
      long long int deno = b[0];
      if (num < 0 && deno > 0) cout << "-";
      if (num > 0 && deno < 0) cout << "-";
      if (num < 0) num = -num;
      if (deno < 0) deno = -deno;
      long long int g = gcd(num, deno);
      num /= g;
      deno /= g;
      cout << num << "/" << deno << "\n";
    }
  }
  return 0;
}
