#include <bits/stdc++.h>
using namespace std;
struct s1 {
  int i, j;
};
bool cp(s1 a2, s1 b2) {
  if (a2.i > b2.i) return (a2.i > b2.i);
};
template <typename T>
T gcd(T a, T b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
int main() {
  long long a, b, r, d = 1, q1, q2, q3;
  int mas[102] = {0}, mas2[102] = {0}, n, m;
  cin >> n >> m;
  int i;
  for (i = 0; i <= n; i++) cin >> mas[i];
  for (i = 0; i <= m; i++) cin >> mas2[i];
  if (mas[0] < 0) d *= -1;
  if (mas2[0] < 0) d *= -1;
  mas[0] = abs(mas[0]);
  mas2[0] = abs(mas2[0]);
  if (n > m) {
    if (mas[0] == mas2[0])
      cout << "1/1";
    else {
      if (d < 0) cout << "-";
      cout << "Infinity";
    }
  }
  if (n < m) cout << "0/1";
  if (n == m) {
    if (d < 0) cout << "-";
    q1 = gcd(mas[0], mas2[0]);
    cout << mas[0] / q1 << "/" << mas2[0] / q1;
  }
  return 0;
}
