#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[150], b[150];
int gcd(int x, int y) {
  if (!x || !y) return x > y ? x : y;
  for (int t; t = x % y; x = y, y = t)
    ;
  return y;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = n; i >= 0; i--) scanf("%d", a + i);
  for (int i = m; i >= 0; i--) scanf("%d", b + i);
  int maxn = -1, maxm = -1;
  for (maxn = n; maxn >= 0 && a[maxn] == 0; maxn--)
    ;
  for (maxm = m; maxm >= 0 && b[maxm] == 0; maxm--)
    ;
  int sign = (a[maxn] * b[maxm] < 0) ? 0 : 1;
  if (maxn < maxm)
    puts("0/1");
  else if (maxn > maxm) {
    if (sign == 0) printf("-");
    puts("Infinity");
  } else {
    int high = abs(a[maxn]), low = abs(b[maxm]);
    int g = gcd(high, low);
    if (sign == 0) printf("-");
    printf("%d/%d\n", high / g, low / g);
  }
  return 0;
}
