#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[1100], b[1100];
int gcd(int c, int d) {
  if (d == 0) return c;
  return gcd(d, c % d);
}
int ABs(int c) {
  if (c >= 0)
    return c;
  else
    return -c;
}
int main() {
  scanf("%d %d", &n, &m);
  int i;
  scanf("%d", &a[0]);
  for (i = 1; i < n + 1; i++) scanf("%d", &a[1]);
  scanf("%d", &b[0]);
  for (i = 1; i < m + 1; i++) scanf("%d", &b[1]);
  if (n == m) {
    int d = gcd(ABs(a[0]), ABs(b[0]));
    a[0] /= d;
    b[0] /= d;
    if (b[0] < 0) {
      a[0] *= -1;
      b[0] *= -1;
    }
    printf("%d/%d\n", a[0], b[0]);
  } else if (n > m) {
    if ((a[0] > 0) ^ (b[0] > 0))
      printf("-Infinity\n");
    else
      printf("Infinity\n");
  } else
    printf("0/1\n");
  return 0;
}
