#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (a < b) swap(a, b);
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  int n, m;
  cin >> n >> m;
  int a0, b0, x;
  for (int i = 0; i < n + 1; i++) {
    cin >> x;
    if (!i) a0 = x;
  }
  for (int i = 0; i < m + 1; i++) {
    cin >> x;
    if (!i) b0 = x;
  }
  if (n > m) {
    int sign;
    if (a0 < 0 && b0 > 0 || a0 > 0 && b0 < 0) cout << "-";
    cout << "Infinity\n";
  } else if (n < m) {
    cout << "0/1\n";
  } else {
    int sign;
    if (a0 < 0 && b0 < 0 || a0 > 0 && b0 > 0)
      sign = 1;
    else
      sign = -1;
    a0 = abs(a0);
    b0 = abs(b0);
    int g = gcd(a0, b0);
    a0 /= g;
    b0 /= g;
    a0 *= sign;
    cout << a0 << "/" << b0 << "\n";
  }
}
