#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, m;
  int i = 0, tmp;
  int P, Q;
  cin >> n >> m;
  i = n;
  cin >> P;
  while (i--) {
    cin >> tmp;
  }
  cin >> Q;
  i = m;
  while (i--) {
    cin >> tmp;
  }
  int sm = 1, sn = 1;
  if (P < 0) sn = -1;
  if (Q < 0) sm = -1;
  if (m == n) {
    if (sm * sn < 0) cout << '-';
    P = (P < 0) ? -P : P;
    Q = (Q < 0) ? -Q : Q;
    int a = P, b = Q;
    while (b) {
      if (a > b)
        a -= b;
      else
        b -= a;
    }
    P /= a;
    Q /= a;
    if (m >= 0) cout << P << '/' << Q << endl;
  } else {
    if (n < m)
      cout << "0/1" << endl;
    else {
      if (sm * sn < 0) cout << '-';
      cout << "Infinity" << endl;
    }
  }
}
