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