1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;

#define FOR(x, b, e) for(int x = (b); x <= (e); ++(x))
#define FORD(x, b, e) for(int x = (b); x >= (e); --(x))
#define REP(x, n) for(int x = 0; x < (n); ++x)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(x) ((int)(x).size())
#define FOREACH(a, b) for (auto&a : (b))
#define PB push_back
#define PF push_front
#define ST first
#define ND second
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl



int n; 
int L;

struct dataaaaa {
  int t;
  int w;
  int next;
  dataaaaa() = default;
  dataaaaa(int t_, int w_, int next_): t(t_), w(w_), next(next_) {};
};


deque<dataaaaa> Q;
vector<deque<int>> obst;
vi wolne;

void rebuildQ(int u) {
  
    stack<dataaaaa> s;
    while (Q.front().t < u) {
      s.push(Q.front());
      Q.pop_front();
    }

    if (u < Q.front().t)
      Q.push_front({u, s.top().w, s.top().next});

    int gnext = Q.front().next;
    while (SIZE(s)) {
      auto d = s.top(); s.pop();
      d.w--;
      if (d.w==1) {
        gnext=d.t;
      }
      Q.push_front({d.t, d.w, min(d.next, gnext)});
    }

}

void createQ(int q) {
  int next = L*q;
  Q.push_back({L*q, 0, next});

  FORD(j, L-1, 0) {
    auto t = j * q;
    if (wolne[j] == 1)
      next = t;
    Q.push_front({t, wolne[j], next});
  }


}

bool sprawdz(int p, int q) {
  createQ(q);
  //
  auto kopia_obst = obst;

  int dod=0;
  vi obsl(n, false);
  while (SIZE(Q)>0) {

    auto d = Q.front();
    int t=d.t, next=d.next;

    REP(i, n) {
      if (obsl[i]) continue;

      auto u = t + p;

      while (SIZE(obst[i])>0 && (obst[i].front() + 1) * q <= t)
        obst[i].pop_front();

      if (u <= next && (obst[i].empty() || u <= obst[i].front() * q)) {
        obsl[i] = true;
        dod++;
        rebuildQ(u); 
        
        /*
        DBG("----");
        DBG(t);
        DBG(i);
        DBG(u);
        DBG(next);
        DBG(Q);
        DBG(obst[i].front());
        DBG(obst[i]);
        DBG(obst[i].empty());
        */
        goto continue2;
      }
    }

    Q.pop_front();
    continue2:;
  }

  obst = kopia_obst;

  return dod == n;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  {

  cin >> n >> L; 



  obst.clear();
  Q.clear();
  wolne.clear();

  wolne.resize(L, 0);
  obst.resize(n);

  REP(i, n) {
    string s; cin >> s;
    REP(j, SIZE(s)) {
      if (s[j] == '.')
        wolne[j]++;
      else
        obst[i].push_back(j);
    }
  }

  // jest zero <-> -1
  bool fail = false;
  FOREACH(x, wolne) {
    if (x == 0) {
      fail = true;
    }
  }

  if (fail) {
    cout << "-1" << endl;
    return 0;
  }

/*
  int p = 2, q = 3;

  auto wyn = sprawdz(p,q);
  if (wyn) {
    DBG("TAK");
  }
  else
  {
    DBG("NIE");
  }

  return 0;
*/

  vector<pair<int,int>> ulamki;

  FOR(p, 0, L)
    FOR(q, 1, n) {
      if (__gcd(p,q) == 1)
        ulamki.emplace_back(p,q);
    }


  sort(ALL(ulamki), [](pair<int,int> a, pair<int,int> b) {
    return a.ST * b.ND < a.ND * b.ST;
  });


  int ret=0;
  FORD(k, __lg(SIZE(ulamki)), 0) {
    int pos = ret + (1<<k);
    if (pos < SIZE(ulamki) && sprawdz(ulamki[pos].ST, ulamki[pos].ND))
      ret += (1<<k);
  }

  cout << ulamki[ret].ST << "/" << ulamki[ret].ND << endl;
  

}}