#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-9;
const long double pi = acos(-1.0);
const long double inf = 1e+9;
long long gcd(long long a, long long b) { return (b == 0) ? a : gcd(b, a % b); }
int xabs(int a) { return a >= 0 ? a : -a; }
int sign(int a) { return (a < 0) ? -1 : 1; }
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n + 1), b(m + 1);
  for (int i = 0; i < n + 1; i++) cin >> a[i];
  for (int i = 0; i < m + 1; i++) cin >> b[i];
  if (n > m) {
    if (a[0] < 0 && b[0] > 0) cout << "-";
    if (a[0] > 0 && b[0] < 0) cout << "-";
    cout << "Infinity" << endl;
  }
  if (n < m) {
    cout << "0/1" << endl;
  }
  if (n == m) {
    int g = gcd(a[0], b[0]);
    a[0] /= g;
    b[0] /= g;
    if (b[0] < 0) {
      a[0] *= -1;
      b[0] *= -1;
    }
    cout << a[0] << "/" << b[0] << endl;
  }
  return 0;
}
