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