#include <bits/stdc++.h>
using namespace std;
const int M = 1000 + 10;
int a[M], b[M];
int gcd(int x, int y) { return y == 0 ? x : gcd(y, x % y); }
int main() {
  int n, m;
  cin >> n >> m;
  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] * b[0] >= 0) {
      cout << "Infinity" << endl;
    } else {
      cout << "-Infinity" << endl;
    }
  }
  if (n == m) {
    int t1 = a[0] < 0 ? -a[0] : a[0];
    int t2 = b[0] < 0 ? -b[0] : b[0];
    int g = gcd(t1, t2);
    a[0] /= g;
    b[0] /= g;
    if (a[0] * b[0] >= 0) {
      if (a[0] > 0) {
        cout << a[0] << "/" << b[0] << endl;
      } else {
        cout << -a[0] << "/" << -b[0] << endl;
      }
    } else {
      if (a[0] >= 0) {
        cout << -a[0] << "/" << -b[0] << endl;
      } else {
        cout << a[0] << "/" << b[0] << endl;
      }
    }
  }
  if (n < m) {
    cout << "0/1" << endl;
  }
  return 0;
}
