#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long lli;
typedef long double ld;
const double E = 0.0000001;
const int INF = 1e7;
#define forn(i, s, f) for (int i = s; i < f; ++i)
#define ft first
#define sec second
#define fora(i, n) for (auto i : n)
#define sz(a) (int)(a).size()
#define sortf0rw(a) sort(a.begin(), a.end())
#define pb push_back
#define mp make_pair
#define fast_ cin.tie(0), ios_base::sync_with_stdio(false);
// ____________________________________________________________

int main() {
    lli mod = 998244353;
    int n;
    int maxn = 201;
    cin >> n;
    vector<int> a(n);
    forn(i, 0, n) cin >> a[i];
    //vector<vector<vector<long> > > dp(n, vector<vector<long> > (maxn, vector<long> (3, 0)));
    vector<vector<lli> > d(maxn, vector<lli> (3, 0)), p(maxn, vector<lli> (3, 0));

    if (a[0] == -1) {
        forn(num, 1, maxn) {
            p[num][0] = 1;
        }
    } else {
        p[a[0]][0] = 1;
    }
    forn(i, 1, n) {
        d = p;
        p.assign(maxn, vector<lli> (3, 0));
        /*forn(num, 1, maxn) {
            cout << d[num][0] << " " << d[num][1] << " " << d[num][2] << " || ";
        } cout << '\n';*/

        if (a[i] == -1) {
            forn(num, 2, maxn) {
                p[num][0] = (p[num - 1][0] + (d[num - 1][0] + d[num - 1][1] + d[num - 1][2]) % mod) % mod;
            }
            forn(num, 1, maxn) {
                p[num][1] = (d[num][0] + d[num][1] + d[num][2]) % mod;
            }
            for (int num = maxn - 2; num >= 0; --num) {
                p[num][2] = (p[num + 1][2] + (d[num + 1][1] + d[num + 1][2]) % mod) % mod;
            }
        } else {
            forn(num, 1, a[i]) {
                p[a[i]][0] = (p[a[i]][0] + (d[num][0] + d[num][1] + d[num][2]) % mod) % mod;
            }
            p[a[i]][1] = (d[a[i]][0] + d[a[i]][1] + d[a[i]][2]) % mod;
            forn(num, a[i] + 1, maxn) {
                p[a[i]][2] = (p[a[i]][2] + (d[num][1] + d[num][2]) % mod) % mod;
            }
        }
    }
    lli ans = 0;
    forn(num, 1, maxn) {
        ans = (ans + p[num][1] + p[num][2]) % mod;
    }
    cout << ans << '\n';

    /*if (a[0] == -1) {
        forn(num, 1, maxn)
            dp[0][num][0] = 1;
    } else {
        dp[0][a[0]][0] = 1;
    }
    forn(i, 1, n) {
        if (a[i] == -1) {
            forn(num, 2, maxn) {
                dp[i][num][0] = (dp[i][num - 1][0] + (dp[i - 1][num - 1][0] +
                    dp[i - 1][num - 1][1] + dp[i - 1][num - 1][2]) % mod) % mod;
            }
            forn(num, 1, maxn) {
                dp[i][num][1] = (dp[i - 1][num][0] + dp[i - 1][num][1] + dp[i - 1][num][2]) % mod;
            }
            for (int num = maxn - 2; num >= 0; --num) {
                dp[i][num][2] = (dp[i][num + 1][2] + (dp[i - 1][num + 1][1] + dp[i - 1][num + 1][2]) % mod) % mod;
            }
        } else {
            forn(num, 1, a[i]) {
                dp[i][a[i]][0] = (dp[i - 1][num][0] + dp[i - 1][num][1] + dp[i - 1][num][2]) % mod;
            }
            dp[i][a[i]][1] = (dp[i - 1][a[i]][0] + dp[i - 1][a[i]][1] + dp[i - 1][a[i]][2]) % mod;
            forn(num, a[i] + 1, maxn) {
                dp[i][a[i]][2] = (dp[i - 1][num][1] + dp[i - 1][num][2]) % mod;
            }
        }
    }
    lli ans = 0;
    forn(num, 1, maxn) {
        ans = (ans + dp[n - 1][num][1] + dp[n - 1][num][2]) % mod;
    }
    cout << ans << '\n';*/
    return 0;

}


#include <bits/stdc++.h>

using namespace std;

#define int long long
//typedef long long ll;
typedef double db;
const int inf = 1000000000000000000;
const int sminf = 1000000000;
const int nowinf = 998244353;

int prost1 = 36028797018963913;
int prost2 = 35184372088777;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
/*
    freopen("input.txt", "r", stdin);

    freopen("output.txt", "w", stdout);
*/

    int kol_vo;
    cin >> kol_vo;
    vector<int> v(kol_vo);
    for(int c=0; c<kol_vo; c++)
        cin >> v[c];
    vector<vector<vector<int> > > dp(kol_vo, vector<vector<int> > (201, vector<int> (2)));
    /// 0 - предыдущий меньше
    /// 1 - предыдущий больше
    if(v[0] == -1){
        for(int c=1; c<=200; c++)
            dp[0][c][0] = 1;
    }
    else {
        dp[0][v[0]][0] = 1;
    }
    for(int c=1; c<kol_vo; c++){
        if(v[c] == -1){
            for(int j=1; j<=200; j++){
                for(int i=1; i<=j; i++)
                    dp[c][j][0] += (dp[c-1][i][0] + dp[c-1][i][1]), dp[c][j][0] %= nowinf;
                for(int i=j; i<=200; i++)
                    dp[c][j][1] += dp[c-1][i][1], dp[c][j][1] %= nowinf;
                dp[c][j][1] += dp[c-1][j][0]; dp[c][j][1] %= nowinf;
            }
        }
        else {
            for(int i=1; i<=v[c]; i++)
                dp[c][v[c]][0] += (dp[c-1][i][0] + dp[c-1][i][1]), dp[c][v[c]][0] %= nowinf;
            for(int i=v[c]; i<=200; i++)
                dp[c][v[c]][1] += dp[c-1][i][1], dp[c][v[c]][1] %= nowinf;
            dp[c][v[c]][1] += dp[c-1][v[c]][0]; dp[c][v[c]][1] %= nowinf;
        }
    }
    int answ = 0;
    for(int c=1; c<=200; c++)
        answ += dp[kol_vo-1][c][1];
    cout << answ;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define int long long
//typedef long long ll;
typedef double db;
const int inf = 1000000000000000000;
const int sminf = 1000000000;
const int nowinf = 998244353;

int prost1 = 36028797018963913;
int prost2 = 35184372088777;

int dp[200001][201][2];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
/*
    freopen("input.txt", "r", stdin);

    freopen("output.txt", "w", stdout);
*/

    int kol_vo;
    cin >> kol_vo;
    vector<int> v(kol_vo);
    for(int c=0; c<kol_vo; c++)
        cin >> v[c];
    for(int c=0; c<200001; c++) for(int i=0; i<201; i++) for(int j=0; j<2; j++) dp[c][i][j] = 0;
    //vector<vector<vector<int> > > dp(kol_vo, vector<vector<int> > (201, vector<int> (2)));
    /// 0 - предыдущий меньше
    /// 1 - предыдущий больше
    if(v[0] == -1){
        for(int c=1; c<=200; c++)
            dp[0][c][0] = 1;
    }
    else {
        dp[0][v[0]][0] = 1;
    }
    for(int c=1; c<kol_vo; c++){
        if(v[c] == -1){
            for(int j=1; j<=200; j++){
                for(int i=1; i<=j; i++)
                    dp[c][j][0] += (dp[c-1][i][0] + dp[c-1][i][1]), dp[c][j][0] %= nowinf;
                for(int i=j; i<=200; i++)
                    dp[c][j][1] += dp[c-1][i][1], dp[c][j][1] %= nowinf;
                dp[c][j][1] += dp[c-1][j][0]; dp[c][j][1] %= nowinf;
            }
        }
        else {
            for(int i=1; i<=v[c]; i++)
                dp[c][v[c]][0] += (dp[c-1][i][0] + dp[c-1][i][1]), dp[c][v[c]][0] %= nowinf;
            for(int i=v[c]; i<=200; i++)
                dp[c][v[c]][1] += dp[c-1][i][1], dp[c][v[c]][1] %= nowinf;
            dp[c][v[c]][1] += dp[c-1][v[c]][0]; dp[c][v[c]][1] %= nowinf;
        }
    }
    int answ = 0;
    for(int c=1; c<=200; c++)
        answ += dp[kol_vo-1][c][1];
    cout << answ;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define int long long
//typedef long long ll;
typedef double db;
const int inf = 1000000000000000000;
const int sminf = 1000000000;
const int nowinf = 998244353;

int prost1 = 36028797018963913;
int prost2 = 35184372088777;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
/*
    freopen("input.txt", "r", stdin);

    freopen("output.txt", "w", stdout);
*/

    int kol_vo;
    cin >> kol_vo;
    vector<int> v(kol_vo);
    for(int c=0; c<kol_vo; c++)
        cin >> v[c];
    vector<vector<vector<int> > > dp(2, vector<vector<int> > (201, vector<int> (2)));
    vector<int> pref1(201);
    vector<int> pref2(201);
    /// 0 - предыдущий меньше
    /// 1 - предыдущий больше
    if(v[0] == -1){
        for(int c=1; c<=200; c++)
            dp[0][c][0] = 1;
    }
    else {
        dp[0][v[0]][0] = 1;
    }
    for(int c=1; c<kol_vo; c++){

        ///переподсчитываем pref
        pref1[0] = dp[0][0][0] + dp[0][0][1];
        for(int i=1; i<201; i++)
            pref1[i] = (pref1[i-1] + dp[0][i][0] + dp[0][i][1]) % nowinf;
        pref2[200] = dp[0][200][1];
        for(int i=199; i>=1; i--)
            pref2[i] = (pref2[i+1] + dp[0][i][1]) % nowinf;

        ///пересчитываем dp
        if(v[c] == -1){
            for(int j=1; j<=200; j++){
                dp[1][j][0] = pref1[j-1]; dp[1][j][0] %= nowinf;
                dp[1][j][1] = pref2[j]; dp[1][j][1] %= nowinf;
                dp[1][j][1] += dp[0][j][0]; dp[1][j][1] %= nowinf;
            }
        }
        else {
            for(int i=1; i<v[c]; i++)
                dp[1][v[c]][0] += (dp[0][i][0] + dp[0][i][1]), dp[1][v[c]][0] %= nowinf;
            for(int i=v[c]; i<=200; i++)
                dp[1][v[c]][1] += dp[0][i][1], dp[1][v[c]][1] %= nowinf;
            dp[1][v[c]][1] += dp[0][v[c]][0]; dp[1][v[c]][1] %= nowinf;
        }

        ///переставляем местами dp
        for(int j=0; j<201; j++){
            for(int i=0; i<2; i++){
                dp[0][j][i] = dp[1][j][i];
                dp[1][j][i] = 0;
            }
        }
    }
    int answ = 0;
    for(int c=1; c<=200; c++)
        answ = (answ + dp[0][c][1]) % nowinf;
    cout << answ;
    return 0;
}


#include <bits/stdc++.h>
#define float long double
using namespace std;

void anime_sila_sport_mogila()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef _47
        freopen("in.cpp", "r", stdin), freopen("out.cpp", "w", stdout);
    #endif
}

const int MOD = 998244353, MAX_N = 1e5 + 47, MAX_VAL = 201;

int n, dp[MAX_N][MAX_VAL][2], a[MAX_N], res;
int t[MAX_VAL * 5][2];

int f(int sum)
{
    if (sum >= MOD) sum -= MOD;
    return sum;
}

void upd(int v, int tl, int tr, int pos, int val, int mod)
{
    t[pos][mod] = f(val);
}

int sum(int v, int tl, int tr, int pos, int mod)
{
    return t[pos][mod];
}

signed main()
{
    anime_sila_sport_mogila();
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    if (a[1] == -1) for (int x = 1; x < MAX_VAL; x++) dp[1][x][0] = 1;
    else dp[1][a[1]][0] = 1;
    for (int i = 2; i <= n; i++)
    {
        for (int last = 1; last < MAX_VAL; last++)
        {
            upd(1, 1, MAX_VAL, last, dp[i - 1][last][0], 0);
            upd(1, 1, MAX_VAL, last, dp[i - 1][last][1], 1);
        }
        int sum1 = 0, sum2 = 0;
        for (int now = 1; now < MAX_VAL; now++)
        {
            if (a[i] != -1 && a[i] != now) continue;
            if (now > 1) dp[i][now][0] = f(dp[i][now - 1][0] + dp[i][now - 1][1]);
            dp[i][now][1] = f(sum(1, 1, MAX_VAL, now, 0) + sum(1, 1, MAX_VAL, now, 1));
        }
        for (int now = MAX_VAL - 1; now >= 1; now--)
        {
            if (a[i] != -1 && a[i] != now) continue;
            dp[i][now][1] = f(dp[i][now][1] + sum2);
            sum2 = f(sum2 + sum(1, 1, MAX_VAL, now, 1));
        }
    }
    for (int x = 1; x < MAX_VAL; x++) if (a[n] == -1 || a[n] == x) res = f(res + dp[n][x][1]);
    cout << res;
    return 0;
}


#include <bits/stdc++.h>
#define float long double
using namespace std;

void anime_sila_sport_mogila()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef _47
        freopen("in.cpp", "r", stdin), freopen("out.cpp", "w", stdout);
    #endif
}

const int MOD = 998244353, MAX_N = 1e5 + 47, MAX_VAL = 301;

int n, dp[MAX_N][MAX_VAL][2], a[MAX_N], res;
long long t[MAX_VAL * 5][2];

int f(long long sum)
{
    while (sum >= MOD) sum -= MOD;
    return sum;
}

void upd(int v, int tl, int tr, int pos, int val, int mod)
{
    t[pos][mod] = f(val);
}

int sum(int v, int tl, int tr, int pos, int mod)
{
    return t[pos][mod];
}

signed main()
{
    anime_sila_sport_mogila();
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    if (a[1] == -1) for (int x = 1; x < MAX_VAL; x++) dp[1][x][0] = 1;
    else dp[1][a[1]][0] = 1;
    for (int i = 2; i <= n; i++)
    {
        for (int last = 1; last < MAX_VAL; last++)
        {
            upd(1, 1, MAX_VAL, last, dp[i - 1][last][0], 0);
            upd(1, 1, MAX_VAL, last, dp[i - 1][last][1], 1);
        }
        long long sum1 = 0, sum2 = 0;
        for (int now = 1; now < MAX_VAL; now++)
        {
            if (a[i] != -1 && a[i] != now) continue;
            if (now > 1) dp[i][now][0] = sum1;
            sum1 = f(sum1 + f(sum(1, 1, MAX_VAL, now, 0) + sum(1, 1, MAX_VAL, now, 1)));
        }
        for (int now = MAX_VAL - 1; now >= 1; now--)
        {
            if (a[i] != -1 && a[i] != now) continue;
            dp[i][now][1] = sum2;
            sum2 = f(sum2 + sum(1, 1, MAX_VAL, now, 1));
            dp[i][now][1] = f(dp[i][now][1] + f(sum(1, 1, MAX_VAL, now, 0) + sum(1, 1, MAX_VAL, now, 1)));
        }
    }
    for (int x = 1; x <= 200; x++) if (a[n] == -1 || a[n] == x) res = f(res + dp[n][x][1]);
    cout << res;
    return 0;
}


#include <bits/stdc++.h>
#define int long long
#define float long double
using namespace std;

void anime_sila_sport_mogila()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef _47
        freopen("in.cpp", "r", stdin), freopen("out.cpp", "w", stdout);
    #endif
}

const int MOD = 998244353, MAX_N = 2e5 + 47, MAX_VAL = 201;

int n, dp[MAX_N][MAX_VAL][2], a[MAX_N], res;

void add(int v, int tl, int tr, int pos, int val, vector<int> &t)
{
    if (tl == tr) t[v] = (t[v] + val) % MOD;
    else
    {
        int tm = (tl + tr) >> 1;
        if (tm >= pos) add(v * 2, tl, tm, pos, val, t);
        else add(v * 2 + 1, tm + 1, tr, pos, val, t);
        t[v] = (t[v * 2] + t[v * 2 + 1]) % MOD;
    }
}

void upd(int v, int tl, int tr, int pos, int val, vector<int> &t)
{
    if (tl == tr) t[v] = val % MOD;
    else
    {
        int tm = (tl + tr) >> 1;
        if (tm >= pos) upd(v * 2, tl, tm, pos, val, t);
        else upd(v * 2 + 1, tm + 1, tr, pos, val, t);
        t[v] = (t[v * 2] + t[v * 2 + 1]) % MOD;
    }
}

int get_sum(int v, int tl, int tr, int l, int r, vector<int> &t)
{
    if (tl > r || tr < l) return 0;
    if (tl >= l && tr <= r) return t[v];
    int tm = (tl + tr) >> 1;
    int q1 = get_sum(v * 2, tl, tm, l, r, t);
    int q2 = get_sum(v * 2 + 1, tm + 1, tr, l, r, t);
    return (q1 + q2) % MOD;
}

signed main()
{
    anime_sila_sport_mogila();
    int n;
    cin >> n;
    vector<int> t0(MAX_VAL * 5), t1(MAX_VAL * 5);
    for (int i = 1; i <= n; i++) cin >> a[i];
    if (a[1] == -1) for (int x = 1; x < MAX_VAL; x++) dp[1][x][0] = 1;
    else dp[1][a[1]][0] = 1;
    for (int i = 2; i <= n; i++)
    {
        for (int last = 1; last < MAX_VAL; last++)
        {
            upd(1, 1, MAX_VAL, last, dp[i - 1][last][0], t0);
            upd(1, 1, MAX_VAL, last, dp[i - 1][last][1], t1);
        }
        for (int now = 1; now < MAX_VAL; now++)
        {
            if (a[i] != -1 && a[i] != now) continue;
            if (now > 1) dp[i][now][0] = (get_sum(1, 1, MAX_VAL, 1, now - 1, t0) + get_sum(1, 1, MAX_VAL, 1, now - 1, t1)) % MOD;
            if (now != 200) dp[i][now][1] = get_sum(1, 1, MAX_VAL, now + 1, MAX_VAL, t1) % MOD;
            dp[i][now][1] = (get_sum(1, 1, MAX_VAL, now, now, t0) + get_sum(1, 1, MAX_VAL, now, now, t1)) % MOD;
        }
    }
    for (int x = 1; x < MAX_VAL; x++) if (a[n] == -1 || a[n] == x) res = (res + dp[n][x][1]) % MOD;
    cout << res;
    return 0;
}


#include <bits/stdc++.h>
#define int long long
#define float long double
using namespace std;

void anime_sila_sport_mogila()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef _47
        freopen("in.cpp", "r", stdin), freopen("out.cpp", "w", stdout);
    #endif
}

const int MOD = 998244353, MAX_N = 1e5 + 47, MAX_VAL = 201;

int dp[MAX_VAL][2][2], n, a[MAX_N];

signed main()
{
    anime_sila_sport_mogila();
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    if (a[1] == -1) for (int x = 1; x < MAX_VAL; x++) dp[x][0][0] = 1;
    else dp[a[1]][0][0] = 1;
    for (int i = 2, mod = 1; i <= n; i++, mod ^= 1)
    {
        for (int x = 1; x < MAX_VAL; x++) dp[x][0][mod] = 0, dp[x][1][mod] = 0;
        int sum1 = 0, sum2 = 0, sum3 = 0;
        for (int x = 1; x < MAX_VAL; x++)
        {
            if (a[i] == -1 || x == a[i])
            {
                dp[x][0][mod] = (sum1 + sum3) % MOD;
                dp[x][1][mod] = (dp[x][1][mod ^ 1] + dp[x][0][mod ^ 1]) % MOD;
            }
            sum1 = (sum1 + dp[x][0][mod ^ 1]) % MOD;
            sum3 = (sum3 + dp[x][1][mod ^ 1]) % MOD;
        }
        for (int x = MAX_VAL - 1; x > 0; x--)
        {
            if (a[i] == -1 || x == a[i]) dp[x][1][mod] = (dp[x][1][mod] + sum2) % MOD;
            sum2 = (sum2 + dp[x][1][mod ^ 1]) % MOD;
        }
        //cout << i << ' ' << mod << ' ' << dp[2][1][mod] << ' ' << dp[2][0][mod] << '\n';
    }
    int ans = 0;
    //cout << ((n & 1) ^ 1) << '\n';
    for (int i = 1; i < MAX_VAL; i++) ans = (ans + dp[i][1][(n & 1) ^ 1]) % MOD;
    cout << ans;
    return 0;
}


#include <bits/stdc++.h>
#define int long long
#define float long double
using namespace std;

void anime_sila_sport_mogila()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef _47
        freopen("in.cpp", "r", stdin), freopen("out.cpp", "w", stdout);
    #endif
}

const int MOD = 998244353, MAX_N = 1e5 + 47, MAX_VAL = 201;

int n, dp[MAX_N][MAX_VAL][2], a[MAX_N], res;

void add(int v, int tl, int tr, int pos, int val, vector<int> &t)
{
    if (tl == tr) t[v] = (t[v] + val) % MOD;
    else
    {
        int tm = (tl + tr) >> 1;
        if (tm >= pos) add(v * 2, tl, tm, pos, val, t);
        else add(v * 2 + 1, tm + 1, tr, pos, val, t);
        t[v] = (t[v * 2] + t[v * 2 + 1]) % MOD;
    }
}

void upd(int v, int tl, int tr, int pos, int val, vector<int> &t)
{
    if (tl == tr) t[v] = val % MOD;
    else
    {
        int tm = (tl + tr) >> 1;
        if (tm >= pos) upd(v * 2, tl, tm, pos, val, t);
        else upd(v * 2 + 1, tm + 1, tr, pos, val, t);
        t[v] = (t[v * 2] + t[v * 2 + 1]) % MOD;
    }
}

int get_sum(int v, int tl, int tr, int l, int r, vector<int> &t)
{
    if (tl > r || tr < l) return 0;
    if (tl >= l && tr <= r) return t[v];
    int tm = (tl + tr) >> 1;
    int q1 = get_sum(v * 2, tl, tm, l, r, t);
    int q2 = get_sum(v * 2 + 1, tm + 1, tr, l, r, t);
    return (q1 + q2) % MOD;
}

signed main()
{
    anime_sila_sport_mogila();
    int n;
    cin >> n;
    vector<int> t0(MAX_VAL * 5), t1(MAX_VAL * 5);
    for (int i = 1; i <= n; i++) cin >> a[i];
    if (a[1] == -1) for (int x = 1; x < MAX_VAL; x++) dp[1][x][0] = 1;
    else dp[1][a[1]][0] = 1;
    for (int i = 2; i <= n; i++)
    {
        for (int last = 1; last < MAX_VAL; last++)
        {
            upd(1, 1, MAX_VAL, last, dp[i - 1][last][0], t0);
            upd(1, 1, MAX_VAL, last, dp[i - 1][last][1], t1);
        }
        for (int now = 1; now < MAX_VAL; now++)
        {
            if (a[i] != -1 && a[i] != now) continue;
            if (now > 1) dp[i][now][0] = (get_sum(1, 1, MAX_VAL, 1, now - 1, t0) + get_sum(1, 1, MAX_VAL, 1, now - 1, t1)) % MOD;
            if (now != 200) dp[i][now][1] = get_sum(1, 1, MAX_VAL, now + 1, MAX_VAL, t1) % MOD;
            dp[i][now][1] = (get_sum(1, 1, MAX_VAL, now, now, t0) + get_sum(1, 1, MAX_VAL, now, now, t1)) % MOD;
        }
    }
    for (int x = 1; x < MAX_VAL; x++) if (a[n] == -1 || a[n] == x) res = (res + dp[n][x][1]) % MOD;
    cout << res;
    return 0;
}


#include <bits/stdc++.h>
#define float long double
using namespace std;

void anime_sila_sport_mogila()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef _47
        freopen("in.cpp", "r", stdin), freopen("out.cpp", "w", stdout);
    #endif
}

const int MOD = 998244353, MAX_N = 1e5 + 47, MAX_VAL = 201;

int n, dp[MAX_N][MAX_VAL][2], a[MAX_N], res;
int t[MAX_VAL * 5][2];

int f(int sum)
{
    while (sum >= MOD) sum -= MOD;
    return sum;
}

void upd(int v, int tl, int tr, int pos, int val, int mod)
{
    t[pos][mod] = f(val);
}

int sum(int v, int tl, int tr, int pos, int mod)
{
    return t[pos][mod];
}

signed main()
{
    anime_sila_sport_mogila();
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    if (a[1] == -1) for (int x = 1; x < MAX_VAL; x++) dp[1][x][0] = 1;
    else dp[1][a[1]][0] = 1;
    for (int i = 2; i <= n; i++)
    {
        for (int last = 1; last < MAX_VAL; last++)
        {
            upd(1, 1, MAX_VAL, last, dp[i - 1][last][0], 0);
            upd(1, 1, MAX_VAL, last, dp[i - 1][last][1], 1);
        }
        int sum1 = 0, sum2 = 0;
        for (int now = 1; now < MAX_VAL; now++)
        {
            if (a[i] != -1 && a[i] != now) continue;
            if (now > 1) dp[i][now][0] = sum1;
            sum1 = f(sum1 + f(sum(1, 1, MAX_VAL, now, 0) + sum(1, 1, MAX_VAL, now, 1)));
        }
        for (int now = MAX_VAL - 1; now >= 1; now--)
        {
            if (a[i] != -1 && a[i] != now) continue;
            dp[i][now][1] = sum2;
            sum2 = f(sum2 + sum(1, 1, MAX_VAL, now, 1));
            dp[i][now][1] = f(dp[i][now][1] + f(sum(1, 1, MAX_VAL, now, 0) + sum(1, 1, MAX_VAL, now, 1)));
        }
    }
    for (int x = 1; x < MAX_VAL; x++) if (a[n] == -1 || a[n] == x) res = f(res + dp[n][x][1]);
    cout << res;
    return 0;
}


#include <bits/stdc++.h>
#define float long double
using namespace std;

void anime_sila_sport_mogila()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef _47
        freopen("in.cpp", "r", stdin), freopen("out.cpp", "w", stdout);
    #endif
}

const int MOD = 998244353, MAX_N = 1e5 + 47, MAX_VAL = 201;

int n, dp[MAX_N][MAX_VAL][2], a[MAX_N], res;
int t[MAX_VAL * 5][2];

int f(int sum)
{
    while (sum >= MOD) sum -= MOD;
    return sum;
}

void upd(int v, int tl, int tr, int pos, int val, int mod)
{
    t[pos][mod] = f(val);
}

int sum(int v, int tl, int tr, int pos, int mod)
{
    return t[pos][mod];
}

signed main()
{
    anime_sila_sport_mogila();
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    if (a[1] == -1) for (int x = 1; x < MAX_VAL; x++) dp[1][x][0] = 1;
    else dp[1][a[1]][0] = 1;
    for (int i = 2; i <= n; i++)
    {
        for (int last = 1; last < MAX_VAL; last++)
        {
            upd(1, 1, MAX_VAL, last, dp[i - 1][last][0], 0);
            upd(1, 1, MAX_VAL, last, dp[i - 1][last][1], 1);
        }
        int sum1 = 0, sum2 = 0;
        for (int now = 1; now < MAX_VAL; now++)
        {
            if (a[i] != -1 && a[i] != now) continue;
            if (now > 1) dp[i][now][0] = f(dp[i][now - 1][0] + dp[i][now - 1][1]);
            dp[i][now][1] = f(sum(1, 1, MAX_VAL, now, 0) + sum(1, 1, MAX_VAL, now, 1));
        }
        for (int now = MAX_VAL - 1; now >= 1; now--)
        {
            if (a[i] != -1 && a[i] != now) continue;
            dp[i][now][1] = f(dp[i][now][1] + sum2);
            sum2 = f(sum2 + sum(1, 1, MAX_VAL, now, 1));
        }
    }
    for (int x = 1; x < MAX_VAL; x++) if (a[n] == -1 || a[n] == x) res = f(res + dp[n][x][1]);
    cout << res;
    return 0;
}


#include <bits/stdc++.h>
#define float long double
using namespace std;

void anime_sila_sport_mogila()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef _47
        freopen("in.cpp", "r", stdin), freopen("out.cpp", "w", stdout);
    #endif
}

const int MOD = 998244353, MAX_N = 1e5 + 47, MAX_VAL = 301;

int n, dp[MAX_N][MAX_VAL][2], a[MAX_N], res;
long long t[MAX_VAL * 5][2];

int f(long long sum)
{
    while (sum >= MOD) sum -= MOD;
    return sum;
}

void upd(int v, int tl, int tr, int pos, int val, int mod)
{
    t[pos][mod] = f(val);
}

int sum(int v, int tl, int tr, int pos, int mod)
{
    return t[pos][mod];
}

signed main()
{
    anime_sila_sport_mogila();
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    if (a[1] == -1) for (int x = 1; x < MAX_VAL; x++) dp[1][x][0] = 1;
    else dp[1][a[1]][0] = 1;
    for (int i = 2; i <= n; i++)
    {
        for (int last = 1; last < MAX_VAL; last++)
        {
            upd(1, 1, MAX_VAL, last, dp[i - 1][last][0], 0);
            upd(1, 1, MAX_VAL, last, dp[i - 1][last][1], 1);
        }
        long long sum1 = 0, sum2 = 0;
        for (int now = 1; now < MAX_VAL; now++)
        {
            if (a[i] != -1 && a[i] != now) continue;
            if (now > 1) dp[i][now][0] = sum1;
            sum1 = f(sum1 + f(sum(1, 1, MAX_VAL, now, 0) + sum(1, 1, MAX_VAL, now, 1)));
        }
        for (int now = MAX_VAL - 1; now >= 1; now--)
        {
            if (a[i] != -1 && a[i] != now) continue;
            dp[i][now][1] = sum2;
            sum2 = f(sum2 + sum(1, 1, MAX_VAL, now, 1));
            dp[i][now][1] = f(dp[i][now][1] + f(sum(1, 1, MAX_VAL, now, 0) + sum(1, 1, MAX_VAL, now, 1)));
        }
    }
    for (int x = 1; x < MAX_VAL; x++) if (a[n] == -1 || a[n] == x) res = f(res + dp[n][x][1]);
    cout << res;
    return 0;
}


#include <bits/stdc++.h>
#define int long long
#define float long double
using namespace std;

void anime_sila_sport_mogila()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef _47
        freopen("in.cpp", "r", stdin), freopen("out.cpp", "w", stdout);
    #endif
}

const int MOD = 998244353, MAX_N = 1e5 + 47, MAX_VAL = 201;

int n, dp[MAX_N][MAX_VAL][2], a[MAX_N], res;

int f(int sum)
{
    if (sum >= MOD) sum -= MOD;
    return sum;
}

void add(int v, int tl, int tr, int pos, int val, vector<int> &t)
{
    if (tl == tr) t[v] = f(t[v] + val);
    else
    {
        int tm = (tl + tr) >> 1;
        if (tm >= pos) add(v * 2, tl, tm, pos, val, t);
        else add(v * 2 + 1, tm + 1, tr, pos, val, t);
        t[v] = f(t[v * 2] + t[v * 2 + 1]);
    }
}

void upd(int v, int tl, int tr, int pos, int val, vector<int> &t)
{
    if (tl == tr) t[v] = f(val);
    else
    {
        int tm = (tl + tr) >> 1;
        if (tm >= pos) upd(v * 2, tl, tm, pos, val, t);
        else upd(v * 2 + 1, tm + 1, tr, pos, val, t);
        t[v] = f(t[v * 2] + t[v * 2 + 1]);
    }
}

int get_sum(int v, int tl, int tr, int l, int r, vector<int> &t)
{
    if (tl > r || tr < l) return 0;
    if (tl >= l && tr <= r) return t[v];
    int tm = (tl + tr) >> 1;
    int q1 = get_sum(v * 2, tl, tm, l, r, t);
    int q2 = get_sum(v * 2 + 1, tm + 1, tr, l, r, t);
    return f(q1 + q2);
}

signed main()
{
    anime_sila_sport_mogila();
    int n;
    cin >> n;
    vector<int> t0(MAX_VAL * 5), t1(MAX_VAL * 5);
    for (int i = 1; i <= n; i++) cin >> a[i];
    if (a[1] == -1) for (int x = 1; x < MAX_VAL; x++) dp[1][x][0] = 1;
    else dp[1][a[1]][0] = 1;
    for (int i = 2; i <= n; i++)
    {
        for (int last = 1; last < MAX_VAL; last++)
        {
            upd(1, 1, MAX_VAL, last, dp[i - 1][last][0], t0);
            upd(1, 1, MAX_VAL, last, dp[i - 1][last][1], t1);
        }
        for (int now = 1; now < MAX_VAL; now++)
        {
            if (a[i] != -1 && a[i] != now) continue;
            if (now > 1) dp[i][now][0] = f(get_sum(1, 1, MAX_VAL, 1, now - 1, t0) + get_sum(1, 1, MAX_VAL, 1, now - 1, t1));
            if (now != 200) dp[i][now][1] = f(get_sum(1, 1, MAX_VAL, now + 1, MAX_VAL, t1));
            dp[i][now][1] = f(get_sum(1, 1, MAX_VAL, now, now, t0) + get_sum(1, 1, MAX_VAL, now, now, t1));
        }
    }
    for (int x = 1; x < MAX_VAL; x++) if (a[n] == -1 || a[n] == x) res = f(res + dp[n][x][1]);
    cout << res;
    return 0;
}


#include <bits/stdc++.h>
#define float long double
using namespace std;

void anime_sila_sport_mogila()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef _47
        freopen("in.cpp", "r", stdin), freopen("out.cpp", "w", stdout);
    #endif
}

const int MOD = 998244353, MAX_N = 1e5 + 47, MAX_VAL = 201;

int n, dp[MAX_N][MAX_VAL][2], a[MAX_N], res;
int t[MAX_VAL * 5][2];

int f(int sum)
{
    if (sum >= MOD) sum -= MOD;
    return sum;
}

void upd(int v, int tl, int tr, int pos, int val, int mod)
{
    if (tl == tr) t[v][mod] = f(val);
    else
    {
        int tm = (tl + tr) >> 1;
        if (tm >= pos) upd(v * 2, tl, tm, pos, val, mod);
        else upd(v * 2 + 1, tm + 1, tr, pos, val, mod);
        t[v][mod] = f(t[v * 2][mod] + t[v * 2 + 1][mod]);
    }
}

int get_sum(int v, int tl, int tr, int l, int r, int mod)
{
    if (tl > r || tr < l) return 0;
    if (tl >= l && tr <= r) return t[v][mod];
    int tm = (tl + tr) >> 1;
    int q1 = get_sum(v * 2, tl, tm, l, r, mod);
    int q2 = get_sum(v * 2 + 1, tm + 1, tr, l, r, mod);
    return f(q1 + q2);
}

signed main()
{
    anime_sila_sport_mogila();
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    if (a[1] == -1) for (int x = 1; x < MAX_VAL; x++) dp[1][x][0] = 1;
    else dp[1][a[1]][0] = 1;
    for (int i = 2; i <= n; i++)
    {
        for (int last = 1; last < MAX_VAL; last++)
        {
            upd(1, 1, MAX_VAL, last, dp[i - 1][last][0], 0);
            upd(1, 1, MAX_VAL, last, dp[i - 1][last][1], 1);
        }
        for (int now = 1; now < MAX_VAL; now++)
        {
            if (a[i] != -1 && a[i] != now) continue;
            if (now > 1) dp[i][now][0] = f(get_sum(1, 1, MAX_VAL, 1, now - 1, 0) + get_sum(1, 1, MAX_VAL, 1, now - 1, 1));
            if (now != 200) dp[i][now][1] = f(get_sum(1, 1, MAX_VAL, now + 1, MAX_VAL, 1));
            dp[i][now][1] = f(get_sum(1, 1, MAX_VAL, now, now, 0) + get_sum(1, 1, MAX_VAL, now, now, 1));
        }
    }
    for (int x = 1; x < MAX_VAL; x++) if (a[n] == -1 || a[n] == x) res = f(res + dp[n][x][1]);
    cout << res;
    return 0;
}


#include <bits/stdc++.h>
#define int long long
#define float long double
using namespace std;

void anime_sila_sport_mogila()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef _47
        freopen("in.cpp", "r", stdin), freopen("out.cpp", "w", stdout);
    #endif
}

const int MOD = 998244353, MAX_N = 1e5 + 47, MAX_VAL = 201;

int dp[MAX_VAL][2][2], n, a[MAX_N];

signed main()
{
    anime_sila_sport_mogila();
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    if (a[1] == -1) for (int x = 1; x < MAX_VAL; x++) dp[x][0][0] = 1;
    else dp[a[1]][0][0] = 1;
    for (int i = 2, mod = 1; i <= n; i++, mod ^= 1)
    {
        for (int x = 1; x < MAX_VAL; x++) dp[x][i][mod] = 0;
        int sum1 = 0, sum2 = 0, sum3 = 0;
        for (int x = 1; x < MAX_VAL; x++)
        {
            if (a[i] == -1 || x == a[i])
            {
                dp[x][0][mod] = (sum1 + sum3) % MOD;
                dp[x][1][mod] = (dp[x][1][mod ^ 1] + dp[x][0][mod ^ 1]) % MOD;
            }
            sum1 = (sum1 + dp[x][0][mod ^ 1]) % MOD;
            sum3 = (sum3 + dp[x][1][mod ^ 1]) % MOD;
        }
        for (int x = MAX_VAL - 1; x > 0; x--)
        {
            if (a[i] == -1 || x == a[i]) dp[x][1][mod] = (dp[x][1][mod] + sum2) % MOD;
            sum2 = (sum2 + dp[x][1][mod ^ 1]) % MOD;
        }
        //cout << i << ' ' << mod << ' ' << dp[2][1][mod] << ' ' << dp[2][0][mod] << '\n';
    }
    int ans = 0;
    //cout << ((n & 1) ^ 1) << '\n';
    for (int i = 1; i < MAX_VAL; i++) ans = (ans + dp[i][1][(n & 1) ^ 1]) % MOD;
    cout << ans;
    return 0;
}


#include <bits/stdc++.h>
#define float long double
using namespace std;

void anime_sila_sport_mogila()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef _47
        freopen("in.cpp", "r", stdin), freopen("out.cpp", "w", stdout);
    #endif
}

const int MOD = 998244353, MAX_N = 1e5 + 47, MAX_VAL = 201;

int n, dp[MAX_N][MAX_VAL][2], a[MAX_N], res;
int t[MAX_VAL * 5][2];

int f(int sum)
{
    if (sum >= MOD) sum -= MOD;
    return sum;
}

void upd(int v, int tl, int tr, int pos, int val, int mod)
{
    if (tl == tr) t[v][mod] = f(val);
    else
    {
        int tm = (tl + tr) >> 1;
        if (tm >= pos) upd(v * 2, tl, tm, pos, val, mod);
        else upd(v * 2 + 1, tm + 1, tr, pos, val, mod);
        t[v][mod] = f(t[v * 2][mod] + t[v * 2 + 1][mod]);
    }
}

int get_sum(int v, int tl, int tr, int l, int r, int mod)
{
    if (tl > r || tr < l) return 0;
    if (tl >= l && tr <= r) return t[v][mod];
    int tm = (tl + tr) >> 1;
    int q1 = get_sum(v * 2, tl, tm, l, r, mod);
    int q2 = get_sum(v * 2 + 1, tm + 1, tr, l, r, mod);
    return f(q1 + q2);
}

int sum(int v, int tl, int tr, int pos, int mod)
{
    if (tl == tr) return t[v][mod];
    int tm = (tl + tr) >> 1;
    if (tm >= pos) return sum(v * 2, tl, tm, pos, mod);
    else return sum(v * 2 + 1, tm + 1, tr, pos, mod);
}

signed main()
{
    anime_sila_sport_mogila();
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    if (a[1] == -1) for (int x = 1; x < MAX_VAL; x++) dp[1][x][0] = 1;
    else dp[1][a[1]][0] = 1;
    for (int i = 2; i <= n; i++)
    {
        for (int last = 1; last < MAX_VAL; last++)
        {
            upd(1, 1, MAX_VAL, last, dp[i - 1][last][0], 0);
            upd(1, 1, MAX_VAL, last, dp[i - 1][last][1], 1);
        }
        int sum1 = 0, sum2 = 0;
        for (int now = 1; now < MAX_VAL; now++)
        {
            if (a[i] != -1 && a[i] != now) continue;
            if (now > 1) dp[i][now][0] = f(dp[i][now - 1][0] + dp[i][now - 1][1]);
            dp[i][now][1] = f(sum(1, 1, MAX_VAL, now, 0) + sum(1, 1, MAX_VAL, now, 1));
        }
        for (int now = MAX_VAL - 1; now >= 1; now--)
        {
            dp[i][now][1] = f(dp[i][now][1] + sum2);
            sum2 = f(sum2 + sum(1, 1, MAX_VAL, now, 1));
        }
    }
    for (int x = 1; x < MAX_VAL; x++) if (a[n] == -1 || a[n] == x) res = f(res + dp[n][x][1]);
    cout << res;
    return 0;
}


#include <bits/stdc++.h>
#define float long double
using namespace std;

void anime_sila_sport_mogila()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef _47
        freopen("in.cpp", "r", stdin), freopen("out.cpp", "w", stdout);
    #endif
}

const int MOD = 998244353, MAX_N = 1e5 + 47, MAX_VAL = 201;

int n, dp[MAX_N][MAX_VAL][2], a[MAX_N], res;
int t[MAX_VAL * 5][2];

int f(int sum)
{
    while (sum >= MOD) sum -= MOD;
    return sum;
}

void upd(int v, int tl, int tr, int pos, int val, int mod)
{
    t[pos][mod] = f(val);
}

int sum(int v, int tl, int tr, int pos, int mod)
{
    return t[pos][mod];
}

signed main()
{
    anime_sila_sport_mogila();
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    if (a[1] == -1) for (int x = 1; x < MAX_VAL; x++) dp[1][x][0] = 1;
    else dp[1][a[1]][0] = 1;
    for (int i = 2; i <= n; i++)
    {
        for (int last = 1; last < MAX_VAL; last++)
        {
            upd(1, 1, MAX_VAL, last, dp[i - 1][last][0], 0);
            upd(1, 1, MAX_VAL, last, dp[i - 1][last][1], 1);
        }
        int sum1 = 0, sum2 = 0;
        for (int now = 1; now < MAX_VAL; now++)
        {
            if (a[i] != -1 && a[i] != now) continue;
            if (now > 1) dp[i][now][0] = sum1;
            sum1 = f(sum1 + f(sum(1, 1, MAX_VAL, now, 0) + sum(1, 1, MAX_VAL, now, 1)));
        }
        for (int now = MAX_VAL - 1; now >= 1; now--)
        {
            if (a[i] != -1 && a[i] != now) continue;
            dp[i][now][1] = f(dp[i][now][1] + sum2);
            sum2 = f(sum2 + sum(1, 1, MAX_VAL, now, 1));
            dp[i][now][1] = f(dp[i][now][1] + f(sum(1, 1, MAX_VAL, now, 0) + sum(1, 1, MAX_VAL, now, 1)));
        }
    }
    for (int x = 1; x < MAX_VAL; x++) if (a[n] == -1 || a[n] == x) res = f(res + dp[n][x][1]);
    cout << res;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;

const int M = 998244353;

int memo[100001][201][2];
int arr[100000];
int N;
int main(){
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) scanf("%d", &arr[i]);

	for (int idx = N; idx >= 0; --idx) {
		for (int n = 1; n <= 200; ++n) {
			for (int t = 0; t <= 1; ++t) {
				if (idx == N) {
					memo[idx][n][t] = 1;
				}
				else {
					if (arr[idx] != -1 && arr[idx] != n) memo[idx][n][t] = 0;
					else {
						if (t == 0) memo[idx][n][t] = ((memo[idx + 1][n][1] - memo[idx + 1][n - 1][1] + M) % M + (memo[idx + 1][200][0] - memo[idx + 1][n][0] + M) %M) %M;
						else if (idx == N - 1 && t == 0) memo[idx][n][t] = 0;
						else memo[idx][n][t] = ((memo[idx + 1][n][1] + memo[idx + 1][200][0]) % M - memo[idx + 1][n][0] + M) % M;

					}
				}
			}
		}
		if (idx != 0) {
			for (int t = 0; t <= 1; ++t) {
				for (int n = 1; n <= 200; ++n) {
					memo[idx][n][t] = (memo[idx][n][t] + memo[idx][n - 1][t]) % M;
				}
			}
		}
	}
	int ret = 0;
	for (int n = 1; n <= 200; ++n) {
		ret = (ret + memo[0][n][0]) % M;
	}
	printf("%d\n", ret);

}


#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;

const int M = 998244353;

int memo[100001][201][2];
int arr[100000];
int N;
int main(){
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) scanf("%d", &arr[i]);

	for (int idx = N; idx >= 0; --idx) {
		for (int n = 1; n <= 200; ++n) {
			for (int t = 0; t <= 1; ++t) {
				if (idx == N) {
					memo[idx][n][t] = 1;
				}
				else {
					if (arr[idx] != -1 && arr[idx] != n) memo[idx][n][t] = 0;
					else {
						if (t == 0) memo[idx][n][t] = ((memo[idx + 1][n][1] - memo[idx + 1][n - 1][1] + M) % M + (memo[idx + 1][200][0] - memo[idx + 1][n][0] + M) %M) %M;
						else memo[idx][n][t] = ((memo[idx + 1][n][1] + memo[idx + 1][200][0]) % M - memo[idx + 1][n][0] + M) % M;
					}
				}
			}
		}
		if (idx != 0) {
			for (int t = 0; t <= 1; ++t) {
				for (int n = 1; n <= 200; ++n) {
					memo[idx][n][t] = (memo[idx][n][t] + memo[idx][n - 1][t]) % M;
				}
			}
		}
	}
	int ret = 0;
	for (int n = 1; n <= 200; ++n) {
		ret = (ret + memo[0][n][0]) % M;
	}
	printf("%d\n", ret);

}


#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;

const int M = 998244353;

int memo[100001][201][2];
int arr[100000];
int N;
int main(){
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) scanf("%d", &arr[i]);

	for (int idx = N - 1; idx >= 0; --idx) {
		for (int n = 1; n <= 200; ++n) {
			for (int t = 0; t <= 1; ++t) {
				int& ret = memo[idx][n][t];
				if (arr[idx] != -1 && arr[idx] != n)ret = 0;
				else if (idx == N - 1) {
					if (t== 0) ret = 0;
					else ret = 1;
				}
				else if (t == 0) memo[idx][n][t] = ((memo[idx + 1][n][1] - memo[idx + 1][n - 1][1] + M) % M + (memo[idx + 1][200][0] - memo[idx + 1][n][0] + M) %M) %M;
				else memo[idx][n][t] = ((memo[idx + 1][n][1] + memo[idx + 1][200][0]) % M - memo[idx + 1][n][0] + M) % M;

			}
		}
		for (int t = 0; t <= 1; ++t) {
			for (int n = 1; n <= 200; ++n) {
				memo[idx][n][t] = (memo[idx][n][t] + memo[idx][n - 1][t]) % M;
			}
		}
	}

	printf("%d\n", memo[0][200][0]);

}


#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;

const int M = 998244353;

int memo[100001][201][2];
int arr[100000];
int N;
int main(){
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) scanf("%d", &arr[i]);

	for (int idx = N; idx >= 0; --idx) {
		for (int n = 1; n <= 200; ++n) {
			for (int t = 0; t <= 1; ++t) {
				if (idx == N) {
					memo[idx][n][t] = 1;
				}
				else {
					if (arr[idx] != -1 && arr[idx] != n) memo[idx][n][t] = 0;
					else {
						if (t == 0) memo[idx][n][t] = ((memo[idx + 1][n][1] - memo[idx + 1][n - 1][1] + M) % M + (memo[idx + 1][200][0] - memo[idx + 1][n][0] + M) %M) %M;
						else if (idx == N - 1 && t == 0) memo[idx][n][t] = 0;
						else if (idx == N - 1 && t == 1) memo[idx][n][t] = 1;
						else memo[idx][n][t] = ((memo[idx + 1][n][1] + memo[idx + 1][200][0]) % M - memo[idx + 1][n][0] + M) % M;

					}
				}
			}
		}
		if (idx != 0) {
			for (int t = 0; t <= 1; ++t) {
				for (int n = 1; n <= 200; ++n) {
					memo[idx][n][t] = (memo[idx][n][t] + memo[idx][n - 1][t]) % M;
				}
			}
		}
	}
	int ret = 0;
	for (int n = 1; n <= 200; ++n) {
		ret = (ret + memo[0][n][0]) % M;
	}
	printf("%d\n", ret);

}


#include <bits/stdc++.h>

using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__); fflush(stderr)
#define forn(i, n) for(int i = 0; i < n; ++i)
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define sqr(x) ((x) * (x))
#define sz(x) x.size()
#define all(x) x.begin(), x.end()

typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<db, db> pdd;
typedef pair<ll, ll> pll;

const int INF = 1e9 + 7, N = 1e5 + 7, MOD = 998244353, M = 202;

int n;
ll dp[N][M][3];
int a[N];
int b[N];

void getCnt()
{
    dp[0][1][0] = 1;
    for (int i = 1; i <= n + 1; ++i)
    {
        int f = a[i] == -1? 1: a[i];
        int e = a[i] == -1? 200: a[i];
        for (int k = f; k <= e; ++k)
        {
            dp[i][k][0] = 0;
            dp[i][k][1] = 0;
            dp[i][k][2] = 0;
            for (int j = 1; j < k; ++j)
                dp[i][k][0] += dp[i - 1][j][0] + dp[i - 1][j][1] + dp[i - 1][j][2];
            dp[i][k][1] = dp[i - 1][k][0] + dp[i - 1][k][1] + dp[i - 1][k][2];
            for (int j = k + 1; j <= 200; ++j)
                dp[i][k][2] += dp[i - 1][j][1] + dp[i - 1][j][2];
            dp[i][k][0] %= MOD;
            dp[i][k][1] %= MOD;
            dp[i][k][2] %= MOD;
        }
    }
}

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

    cin >> n;

    for (int i = 1; i <= n; ++i)
        cin >> a[i];

    getCnt();

    cout << dp[n + 1][0][2];

    return 0;
}


#include <cstring>
#include <string.h>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <bitset>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <fstream>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <vector>
#include <set>
#include <complex>
#include <list>
#include <valarray>
#include <memory.h>
#include <climits>
using namespace std;

#define PB                      push_back
#define MP                      make_pair
#define ALL(v)                  v.begin(),v.end()
#define SZ(v)                   (int)v.size()
#define CLR(v, d)               memset(v, d, sizeof(v))

const int OO = (int) 2e9;
const double EPS = 1e-9;

int DI[] = { -1, 0, 1, 0, 1, -1, -1, 1 };
int DJ[] = { 0, 1, 0, -1, 1, -1, 1, -1 };

string g[1001];
int n, m, d;
set<pair<int, int> > cells, died;
vector<pair<int, int> > rats;

void go(int i, int j, bool t) {
    queue<pair<int, int> > q;
    set<pair<int, int> > vis;
    int lvl = d;
    q.push(MP(i, j));
    vis.insert(MP(i, j));
    if (t && g[i][j] == 'R')
        died.insert(MP(i, j));
    cells.insert(MP(i, j));
    while (SZ(q) ) {
        if (lvl == 0)
            break;
        int sz = SZ(q);
        while (sz--) {
            i = q.front().first;
            j = q.front().second;
            q.pop();

            for (int k = 0; k < 4; k++) {
                int ni = i + DI[k];
                int nj = j + DJ[k];
                if (ni < 0 || ni >= n || nj < 0 || nj >= m)
                    continue;
                if (vis.find(MP(ni, nj)) != vis.end())
                    continue;
                if (g[ni][nj] == 'X')
                    continue;
                vis.insert(MP(ni, nj));
                cells.insert(MP(ni, nj));

                if (t && g[ni][nj] == 'R')
                    died.insert(MP(ni, nj));

                q.push(MP(ni, nj));
            }
        }
        lvl--;
    }
}

inline int dist(int i, int j, int i2, int j2) {
    return abs(i - i2) + abs(j - j2);
}
int main() {

  freopen("input.txt", "rt", stdin);
   freopen("output.txt", "wt", stdout);

    cin >> n >> m >> d;
    for (int i = 0; i < n; i++)
        cin >> g[i];

    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            if (g[i][j] == 'R')
                rats.push_back(MP(i, j));

    vector<pair<int, int> > cand;

    for (int i = 0; i < n; i++) {
        if (SZ(cand) == 1)
            break;
        for (int j = 0; j < m; j++) {
            if (SZ(cand) == 1)
                break;
            if (g[i][j] == 'R')
                cand.push_back(MP(i, j));
        }
    }

    for (int i = n - 1; i >= 0; i--) {
        if (SZ(cand) == 2)
            break;
        for (int j = m - 1; j >= 0; j--) {
            if (SZ(cand) == 2)
                break;
            if (g[i][j] == 'R' && i != cand[0].first && j != cand[0].second)
                cand.push_back(MP(i, j));
        }
    }

    if (SZ(cand) == 2) {

        for (int i = n / 2; i < n; i++) {
            if (SZ(cand) == 6)
                break;
            for (int j = 0; j < m; j++) {
                if (SZ(cand) == 3)
                    break;
                if (g[i][j] == 'R' && i != cand.back().first)
                    cand.push_back(MP(i, j));
            }
        }

    }

    if (SZ(cand) == 1) {
        // only one rat
        for (int i = 0; i < n; i++) {
            if (SZ(cand) == 2)
                break;
            for (int j = 0; j < m; j++) {
                if (SZ(cand) == 2)
                    break;
                if (g[i][j] == '.')
                    cand.push_back(MP(i, j));
            }
        }
    }

    for (int i = 0; i < 2; i++)
        go(cand[i].first, cand[i].second, false);

    vector<pair<int, int> > v(ALL(cells));

    for (int i = 0; i < SZ(v) ; i++)
        for (int j = 0; j < SZ(v) ; j++)
            if (i != j) {
                died.clear();
                go(v[i].first, v[i].second, true);
                go(v[j].first, v[j].second, true);
                if (SZ(died) == SZ(rats)) {
                    cout << v[i].first + 1 << " " << v[i].second + 1 << " "
                            << v[j].first + 1 << " " << v[j].second + 1;
                    return 0;
                }
            }

    cout << -1;
    return 0;
}


#include <cstring>
#include <string.h>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <bitset>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <fstream>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <vector>
#include <set>
#include <complex>
#include <list>
#include <valarray>
#include <memory.h>
#include <climits>
using namespace std;

#define PB                      push_back
#define MP                      make_pair
#define ALL(v)                  v.begin(),v.end()
#define SZ(v)                   (int)v.size()
#define CLR(v, d)               memset(v, d, sizeof(v))

const int OO = (int) 2e9;
const double EPS = 1e-9;

int DI[] = { -1, 0, 1, 0, 1, -1, -1, 1 };
int DJ[] = { 0, 1, 0, -1, 1, -1, 1, -1 };

string g[1001];
int n, m, d;
set<pair<int, int> > cells, died;
vector<pair<int, int> > rats;

void go(int i, int j, bool t) {
    queue<pair<int, int> > q;
    set<pair<int, int> > vis;
    int lvl = d;
    q.push(MP(i, j));
    vis.insert(MP(i, j));
    if (t && g[i][j] == 'R')
        died.insert(MP(i, j));
    cells.insert(MP(i, j));
    while (SZ(q) ) {
        if (lvl == 0)
            break;
        int sz = SZ(q);
        while (sz--) {
            i = q.front().first;
            j = q.front().second;
            q.pop();

            for (int k = 0; k < 4; k++) {
                int ni = i + DI[k];
                int nj = j + DJ[k];
                if (ni < 0 || ni >= n || nj < 0 || nj >= m)
                    continue;
                if (vis.find(MP(ni, nj)) != vis.end())
                    continue;
                if (g[ni][nj] == 'X')
                    continue;
                vis.insert(MP(ni, nj));
                cells.insert(MP(ni, nj));

                if (t && g[ni][nj] == 'R')
                    died.insert(MP(ni, nj));

                q.push(MP(ni, nj));
            }
        }
        lvl--;
    }
}

inline int dist(int i, int j, int i2, int j2) {
    return abs(i - i2) + abs(j - j2);
}
int main() {

 freopen("input.txt", "rt", stdin);
   freopen("output.txt", "wt", stdout);

    cin >> n >> m >> d;
    for (int i = 0; i < n; i++)
        cin >> g[i];

    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            if (g[i][j] == 'R')
                rats.push_back(MP(i, j));

    vector<pair<int, int> > cand;

    for (int i = 0; i < n; i++) {
        if (SZ(cand) == 1)
            break;
        for (int j = 0; j < m; j++) {
            if (SZ(cand) == 1)
                break;
            if (g[i][j] == 'R')
                cand.push_back(MP(i, j));
        }
    }

    for (int i = n - 1; i >= 0; i--) {
        if (SZ(cand) == 2)
            break;
        for (int j = m - 1; j >= 0; j--) {
            if (SZ(cand) == 2)
                break;
            if (g[i][j] == 'R' && i != cand[0].first && j != cand[0].second)
                cand.push_back(MP(i, j));
        }
    }

    if (SZ(cand) == 2) {

        for (int i = n / 2; i < n; i++) {
            if (SZ(cand) == 3)
                break;
            for (int j = 0; j < m; j++) {
                if (SZ(cand) == 3)
                    break;
                if (g[i][j] == 'R' && i != cand[0].first && j != cand[0].second
                        && i != cand[1].first && j != cand[1].second)
                    cand.push_back(MP(i, j));
            }
        }

    }

    if (SZ(cand) == 3) {

        for (int i = n / 2; i >= 0; i--) {
            if (SZ(cand) == 4)
                break;
            for (int j = m - 1; j >= 0; j--) {
                if (SZ(cand) == 4)
                    break;
                if (g[i][j] == 'R' && i != cand[0].first && j != cand[0].second
                        && i != cand[1].first && j != cand[1].second
                        && i != cand[2].first && j != cand[2].second)
                    cand.push_back(MP(i, j));
            }
        }

    }

    if (SZ(cand) == 1) {
        // only one rat
        for (int i = 0; i < n; i++) {
            if (SZ(cand) == 2)
                break;
            for (int j = 0; j < m; j++) {
                if (SZ(cand) == 2)
                    break;
                if (g[i][j] == '.')
                    cand.push_back(MP(i, j));
            }
        }
    }

    for (int i = 0; i < 2; i++)
        go(cand[i].first, cand[i].second, false);

    vector<pair<int, int> > v(ALL(cells));

    for (int i = 0; i < SZ(v) ; i++)
        for (int j = 0; j < SZ(v) ; j++)
            if (i != j) {
                died.clear();
                go(v[i].first, v[i].second, true);
                go(v[j].first, v[j].second, true);
                if (SZ(died) == SZ(rats)) {
                    cout << v[i].first + 1 << " " << v[i].second + 1 << " "
                            << v[j].first + 1 << " " << v[j].second + 1;
                    return 0;
                }
            }

    cout << -1;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define PB                      push_back
#define MP                      make_pair
#define ALL(v)                  v.begin(),v.end()
#define SZ(v)                   (int)v.size()
#define CLR(v, d)               memset(v, d, sizeof(v))

const int OO = (int) 2e9;
const double EPS = 1e-9;

int DI[] = { -1, 0, 1, 0, 1, -1, -1, 1 };
int DJ[] = { 0, 1, 0, -1, 1, -1, 1, -1 };

string g[1001];
int n, m, d;
set<pair<int, int> > cells;
vector<pair<int, int> > rats;

void go(int i, int j) {
    queue<pair<int, int> > q;
    set<pair<int, int> > vis;
    int lvl = d;
    q.push(MP(i, j));
    vis.insert(MP(i, j));
    cells.insert(MP(i, j));
    while (SZ(q) ) {
        if (lvl == 0)
            break;
        int sz = SZ(q);
        while (sz--) {
            i = q.front().first;
            j = q.front().second;
            q.pop();

            for (int k = 0; k < 4; k++) {
                int ni = i + DI[k];
                int nj = j + DJ[k];
                if (ni < 0 || ni >= n || nj < 0 || nj >= m)
                    continue;
                if (vis.find(MP(ni, nj)) != vis.end())
                    continue;
                if (g[ni][nj] == 'X')
                    continue;
                vis.insert(MP(ni, nj));
                cells.insert(MP(ni, nj));
                q.push(MP(ni, nj));
            }
        }
        lvl--;
    }
}

inline int dist(int i, int j, int i2, int j2) {
    return abs(i - i2) + abs(j - j2);
}
int main() {
    //freopen("in.txt", "rt", stdin);
    cin >> n >> m >> d;
    for (int i = 0; i < n; i++)
        cin >> g[i];

    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            if (g[i][j] == 'R')
                rats.push_back(MP(i, j));

    vector<pair<int, int> > cand;

    for (int i = 0; i < n; i++) {
        if (SZ(cand) == 2)
            break;
        for (int j = 0; j < m; j++) {
            if (SZ(cand) == 2)
                break;
            if (g[i][j] == 'R')
                cand.push_back(MP(i, j));
        }
    }

    if (SZ(cand) == 1) {
        // only one rat
        for (int i = 0; i < n; i++) {
            if (SZ(cand) == 2)
                break;
            for (int j = 0; j < m; j++) {
                if (SZ(cand) == 2)
                    break;
                if (g[i][j] == '.')
                    cand.push_back(MP(i, j));
            }
        }
    }

    for (int i = 0; i < 2; i++)
        go(cand[i].first, cand[i].second);

    vector<pair<int, int> > v(ALL(cells));

    for (int i = 0; i < SZ(v) ; i++)
        for (int j = 0; j < SZ(v) ; j++)
            if (i != j) {
                int cnt = 0;
                for (int k = 0; k < SZ(rats) ; k++) {
                    if ((dist(v[i].first, v[i].second, rats[k].first,
                            rats[k].second) <= d)
                            || (dist(v[j].first, v[j].second, rats[k].first,
                                    rats[k].second) <= d))
                        cnt++;
                    else
                        break;

                }
                if (cnt == SZ(rats)) {
                    cout << v[i].first + 1 << " " << v[i].second + 1 << " "
                            << v[j].first + 1 << " " << v[j].second + 1 << endl;
                    return 0;
                }
            }

    cout << -1 << endl;
    return 0;
}


/*
 * File:     test.cpp
 * Author:   Hrayr [HarHro94]
 * Problem:  Codeforces
 * IDE:      Codeblocks 10.05
 */
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;

const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};

int n, m, d, curColor, used[1007][1007], num[1007][1007], mark[1007], tmp[1007];
char st[1007][1007];

vector<int> Bfs(int sx, int sy);

int main()
{
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    int i, j, sx, sy, i1, i2, i3, i4, tx, ty, cnt=0, x1=-1, x2=-1, y1=-1, y2=-1, firstColor;
    vector<pair<int, int> > pt;
    vector<int> v1, v2, v3, v4;
    scanf("%d%d%d", &n, &m, &d);
    for(i=0;i<n;++i)
    {
        scanf("%s", &st[i]);
        for(j=0;j<m;++j)
        {
            if (st[i][j]=='R')
            {
                sx=i;
                sy=j;
                ++cnt;
            }
        }
    }
    if (cnt>400)
    {
        printf("-1\n");
    }
    cnt=0;
    for(i=0;i<n;++i)
    {
        for(j=0;j<m;++j)
        {
            if (st[i][j]=='R')
            {
                pt.push_back(make_pair(i, j));
                num[i][j]=cnt;
                ++cnt;
            }
        }
    }
    v1=Bfs(sx, sy);
    for(i1=0;i1<v1.size();i1+=2)
    {
        sx=v1[i1];
        sy=v1[i1+1];
        x1=sx;
        y1=sy;
        v2=Bfs(sx, sy);
        for(i=0;i<pt.size();++i)
        {
            mark[i]=0;
        }
        for(i2=0;i2<v2.size();i2+=2)
        {
            tx=v2[i2];
            ty=v2[i2+1];
            if (st[tx][ty]=='R')
            {
                mark[num[tx][ty]]=1;
            }
        }
        firstColor=curColor;
        sx=-1;
        sy=-1;
        for(i=0;i<pt.size();++i)
        {
            tx=pt[i].first;
            ty=pt[i].second;
            if (used[tx][ty]!=firstColor)
            {
                sx=tx;
                sy=ty;
                break;
            }
        }
        if (sx==-1)
        {
            for(i=0;i<n;++i)
            {
                for(j=0;j<m;++j)
                {
                    if (st[i][j]=='.' && !(i==x1 && j==y1))
                    {
                        x2=i;
                        y2=j;
                        goto PRINT;
                    }
                }
            }
        }
        v3=Bfs(sx, sy);
        for(i3=0;i3<v3.size();i3+=2)
        {
            sx=v3[i3];
            sy=v3[i3+1];
            for(i=0;i<pt.size();++i)
            {
                tmp[i]=mark[i];
            }
            v4=Bfs(sx, sy);
            for(i4=0;i4<v4.size();i4+=2)
            {
                tx=v4[i4];
                ty=v4[i4+1];
                if (st[tx][ty]=='R')
                {
                    mark[num[tx][ty]]=1;
                }
            }
            bool flag=1;
            for(i=0;i<pt.size();++i)
            {
                if (mark[i]==0)
                {
                    flag=0;
                }
            }
            if (flag)
            {
                x2=sx;
                y2=sy;
                goto PRINT;
            }
        }
    }
PRINT:
    if (x1==-1 || x2==-1)
    {
        printf("-1\n");
    }
    else
    {
        printf("%d %d %d %d\n", x1+1, y1+1, x2+1, y2+1);
    }
    return 0;
}

vector<int> Bfs(int sx, int sy)
{
    int i, dis, tx, ty;
    vector<int> ret;
    ++curColor;
    queue<int> Q;
    Q.push(sx);
    Q.push(sy);
    Q.push(0);
    used[sx][sy]=curColor;
    while(!Q.empty())
    {
        sx=Q.front();Q.pop();
        sy=Q.front();Q.pop();
        dis=Q.front();Q.pop();
        ret.push_back(sx);
        ret.push_back(sy);
        for(i=0;i<4;++i)
        {
            tx=sx+dx[i];
            ty=sy+dy[i];
            if (st[tx][ty]!='X' && used[tx][ty]!=curColor && dis<d)
            {
                used[tx][ty]=curColor;
                Q.push(tx);
                Q.push(ty);
                Q.push(dis+1);
            }
        }
    }
    return ret;
}


/*
 * File:     test.cpp
 * Author:   Hrayr [HarHro94]
 * Problem:  Codeforces
 * IDE:      Codeblocks 10.05
 */
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;

const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};

int n, m, d, curColor, used[1007][1007], num[1007][1007], mark[1007], tmp[1007];
char st[1007][1007];

vector<int> Bfs(int sx, int sy);

int main()
{
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    int i, j, sx, sy, i1, i2, i3, i4, tx, ty, cnt=0, x1=-1, x2=-1, y1=-1, y2=-1, firstColor;
    vector<pair<int, int> > pt;
    vector<int> v1, v2, v3, v4;
    scanf("%d%d%d", &n, &m, &d);
    for(i=0;i<n;++i)
    {
        scanf("%s", &st[i]);
        for(j=0;j<m;++j)
        {
            if (st[i][j]=='R')
            {
                sx=i;
                sy=j;
                ++cnt;
            }
        }
    }
    if (cnt>400)
    {
        printf("-1\n");
        return 0;
    }
    cnt=0;
    for(i=0;i<n;++i)
    {
        for(j=0;j<m;++j)
        {
            if (st[i][j]=='R')
            {
                pt.push_back(make_pair(i, j));
                num[i][j]=cnt;
                ++cnt;
            }
        }
    }
    v1=Bfs(sx, sy);
    for(i1=0;i1<v1.size();i1+=2)
    {
        sx=v1[i1];
        sy=v1[i1+1];
        x1=sx;
        y1=sy;
        v2=Bfs(sx, sy);
        for(i=0;i<pt.size();++i)
        {
            mark[i]=0;
        }
        for(i2=0;i2<v2.size();i2+=2)
        {
            tx=v2[i2];
            ty=v2[i2+1];
            if (st[tx][ty]=='R')
            {
                mark[num[tx][ty]]=1;
            }
        }
        sx=-1;
        sy=-1;
        for(i=0;i<pt.size();++i)
        {
            if (mark[i]==0)
            {
                sx=pt[i].first;
                sy=pt[i].second;
                break;
            }
        }
        if (sx==-1)
        {
            for(i=0;i<n;++i)
            {
                for(j=0;j<m;++j)
                {
                    if (st[i][j]=='.' && !(i==x1 && j==y1))
                    {
                        x2=i;
                        y2=j;
                        goto PRINT;
                    }
                }
            }
        }
        v3=Bfs(sx, sy);
        for(i3=0;i3<v3.size();i3+=2)
        {
            sx=v3[i3];
            sy=v3[i3+1];
            for(i=0;i<pt.size();++i)
            {
                tmp[i]=mark[i];
            }
            v4=Bfs(sx, sy);
            for(i4=0;i4<v4.size();i4+=2)
            {
                tx=v4[i4];
                ty=v4[i4+1];
                if (st[tx][ty]=='R')
                {
                    tmp[num[tx][ty]]=1;
                }
            }
            bool flag=1;
            for(i=0;i<pt.size();++i)
            {
                if (tmp[i]==0)
                {
                    flag=0;
                }
            }
            if (flag)
            {
                x2=sx;
                y2=sy;
                goto PRINT;
            }
        }
    }
PRINT:
    if (x1==-1 || x2==-1)
    {
        printf("-1\n");
    }
    else
    {
        printf("%d %d %d %d\n", x1+1, y1+1, x2+1, y2+1);
    }
    return 0;
}

vector<int> Bfs(int sx, int sy)
{
    int i, dis, tx, ty;
    vector<int> ret;
    ++curColor;
    queue<int> Q;
    Q.push(sx);
    Q.push(sy);
    Q.push(0);
    used[sx][sy]=curColor;
    while(!Q.empty())
    {
        sx=Q.front();Q.pop();
        sy=Q.front();Q.pop();
        dis=Q.front();Q.pop();
        ret.push_back(sx);
        ret.push_back(sy);
        for(i=0;i<4;++i)
        {
            tx=sx+dx[i];
            ty=sy+dy[i];
            if (st[tx][ty]!='X' && used[tx][ty]!=curColor && dis<d)
            {
                used[tx][ty]=curColor;
                Q.push(tx);
                Q.push(ty);
                Q.push(dis+1);
            }
        }
    }
    return ret;
}


/*
 * File:     test.cpp
 * Author:   Hrayr [HarHro94]
 * Problem:  Codeforces
 * IDE:      Codeblocks 10.05
 */
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;

const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};

int n, m, d, curColor, used[1007][1007], num[1007][1007], mark[1007], tmp[1007];
char st[1007][1007];

vector<int> Bfs(int sx, int sy);

int main()
{
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    int i, j, sx, sy, i1, i2, i3, i4, tx, ty, cnt=0, x1=-1, x2=-1, y1=-1, y2=-1, firstColor;
    vector<pair<int, int> > pt;
    vector<int> v1, v2, v3, v4;
    scanf("%d%d%d", &n, &m, &d);
    for(i=0;i<n;++i)
    {
        scanf("%s", &st[i]);
        for(j=0;j<m;++j)
        {
            if (st[i][j]=='R')
            {
                sx=i;
                sy=j;
                ++cnt;
            }
        }
    }
    if (cnt>400)
    {
        printf("-1\n");
    }
    cnt=0;
    for(i=0;i<n;++i)
    {
        for(j=0;j<m;++j)
        {
            if (st[i][j]=='R')
            {
                pt.push_back(make_pair(i, j));
                num[i][j]=cnt;
                ++cnt;
            }
        }
    }
    v1=Bfs(sx, sy);
    for(i1=0;i1<v1.size();i1+=2)
    {
        sx=v1[i1];
        sy=v1[i1+1];
        x1=sx;
        y1=sy;
        v2=Bfs(sx, sy);
        for(i=0;i<pt.size();++i)
        {
            mark[i]=0;
        }
        for(i2=0;i2<v2.size();i2+=2)
        {
            tx=v2[i2];
            ty=v2[i2+1];
            if (st[tx][ty]=='R')
            {
                mark[num[tx][ty]]=1;
            }
        }
        sx=-1;
        sy=-1;
        for(i=0;i<pt.size();++i)
        {
            if (mark[i]==0)
            {
                sx=pt[i].first;
                sy=pt[i].second;
                break;
            }
        }
        if (sx==-1)
        {
            for(i=0;i<n;++i)
            {
                for(j=0;j<m;++j)
                {
                    if (st[i][j]=='.' && !(i==x1 && j==y1))
                    {
                        x2=i;
                        y2=j;
                        goto PRINT;
                    }
                }
            }
        }
        v3=Bfs(sx, sy);
        for(i3=0;i3<v3.size();i3+=2)
        {
            sx=v3[i3];
            sy=v3[i3+1];
            for(i=0;i<pt.size();++i)
            {
                tmp[i]=mark[i];
            }
            v4=Bfs(sx, sy);
            for(i4=0;i4<v4.size();i4+=2)
            {
                tx=v4[i4];
                ty=v4[i4+1];
                if (st[tx][ty]=='R')
                {
                    tmp[num[tx][ty]]=1;
                }
            }
            bool flag=1;
            for(i=0;i<pt.size();++i)
            {
                if (tmp[i]==0)
                {
                    flag=0;
                }
            }
            if (flag)
            {
                x2=sx;
                y2=sy;
                goto PRINT;
            }
        }
    }
PRINT:
    if (x1==-1 || x2==-1)
    {
        printf("-1\n");
    }
    else
    {
        printf("%d %d %d %d\n", x1+1, y1+1, x2+1, y2+1);
    }
    return 0;
}

vector<int> Bfs(int sx, int sy)
{
    int i, dis, tx, ty;
    vector<int> ret;
    ++curColor;
    queue<int> Q;
    Q.push(sx);
    Q.push(sy);
    Q.push(0);
    used[sx][sy]=curColor;
    while(!Q.empty())
    {
        sx=Q.front();Q.pop();
        sy=Q.front();Q.pop();
        dis=Q.front();Q.pop();
        ret.push_back(sx);
        ret.push_back(sy);
        for(i=0;i<4;++i)
        {
            tx=sx+dx[i];
            ty=sy+dy[i];
            if (st[tx][ty]!='X' && used[tx][ty]!=curColor && dis<d)
            {
                used[tx][ty]=curColor;
                Q.push(tx);
                Q.push(ty);
                Q.push(dis+1);
            }
        }
    }
    return ret;
}


 # include <iostream>
 # include <cstdio>
 # include <cstdlib>
 # include <queue>
 # include <algorithm>
 # define mp make_pair
 # define xx first
 # define yy second

 using namespace std;

 const int N = 1002;

 int dx[] = {N, 1, -1, 0, 0};
 int dy[] = {N, 0, 0, 1, -1};
 int cnt1, cnt2, n, m, d, x[N], y[N], u[N], cnt, M[N][N], cor[N][N];
 int sx[N], sy[N], sx2[N], sy2[N], len, prevcol = -2;
 char a[N][N];

 int bfs(int x1, int y1, int col, bool ok = 1) {
      int c = 0;
      if(a[x1][y1] == 'R' && (col == prevcol)) c ++;
      else if(a[x1][y1] == 'R' && cor[x1][y1] != prevcol) c ++;
      if(col == prevcol && a[x1][y1] == 'R') cor[x1][y1] = col;

      for (int ww = 1; ww <= x[0]; ++ww)
      if(x[ww] == x1 && y[ww] == y1) {
          u[ww] = col;
          break;
      }
      queue < pair <int, int> > Q, Q2;
      M[x1][y1] = col;
      Q.push(mp(x1, y1));
      if(!ok && col == 1) {
             sx[0] ++;
             sx[sx[0]] = x1; sy[sx[0]] = y1;
      }
      if(!ok && col > 1) {
             sx2[0] ++;
             sx2[sx2[0]] = x1;
             sy2[sx2[0]] = y1;
      }

      for (int i = 1; i <= d; ++i) {
          Q2 = Q;
          while(!Q.empty()) Q.pop();
          while (!Q2.empty()) {
                pair <int, int> t = Q2.front();
                for (int k = 1; k <= 4; ++k) {
                    int cx = t.xx + dx[k];
                    int cy = t.yy + dy[k];
                    if(cx >= 1 && cx <= n && cy >= 1 && cy <= m)
                    if(M[cx][cy] != col && a[cx][cy] != 'X') {
                        if(!ok && col == 1) { sx[0] ++; sx[sx[0]] = cx; sy[sx[0]] = cy; }
                        else if(!ok) { sx2[0] ++; sx2[sx2[0]] = cx; sy2[sx2[0]] = cy; }
                        if(a[cx][cy] == 'R') {
                            if((cor[cx][cy] != prevcol && col != prevcol) || col == prevcol) c ++;
                            if(col == prevcol) cor[cx][cy] = col;
                            for (int ww = 1; ww <= x[0]; ++ww)
                            if(x[ww] == cx && y[ww] == cy) {
                               u[ww] = col;
                               break;
                            }
                        }
                        M[cx][cy] = col;
                        Q.push(mp(cx, cy));
                    }
                }
                Q2.pop();
          }
      }

      return c;
 }

 int main () {

     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);

     scanf("%d%d%d", &n, &m, &d);

     for (int i = 1; i <= n; ++i)
         for (int j = 1; j <= m; ++j) {
             cin >> a[i][j];
             if(a[i][j] == 'R') {
               ++x[0]; x[x[0]] = i; y[x[0]] = j;
             }
         }

     u[1] = 1;
     cnt1 = bfs(x[1], y[1], ++cnt, 0);

     for (int rr = 1; rr <= sx[0]; ++rr) {
        prevcol = ++cnt;

        cnt1 = bfs(sx[rr], sy[rr], cnt);

        if(cnt1 == x[0]) {
                for (int i = 1; i <= n; ++i) {
                    for (int j = 1; j <= m; ++j) {
                        if(i != sx[rr] && j != sy[rr] && a[i][j] != 'X') {
                             cout << i << ' ' << j << sx[rr] << ' ' << sy[rr] << endl;
                             return 0;
                        }
                    }
                }
        }

        for (int ii = 1; ii <= x[0]; ++ii) {
           if(u[ii] != cnt) {
               sx2[0] = 0;
               cnt2 = bfs(x[ii], y[ii], ++cnt, 0);
               break;
           }
        }

        for (int i1 = 1; i1 <= sx2[0]; ++i1) {
            cnt2 = bfs(sx2[i1], sy2[i1], ++cnt);

           // if(sx2[i1] == 6 && sy2[i1] == 6) cout << cnt2 << endl;
            if(cnt1 + cnt2 == x[0]) {
                    //cout << cnt << endl;
                    //cout << x[0] << ' ' << cnt1 << ' ' << cnt2 << endl;
                    //cout << cnt1 << ' ' << cnt2 << ' ' << prevcol << '\n';
                    /*for (int i = 1; i <= n; ++i) {
                          for (int j = 1; j <= m; ++j) {
                              cout << M[i][j] << ' ';
                          }
                          cout << endl;
                    }*/
                   cout << sx[rr] << ' ' << sy[rr] << ' ' << sx2[i1] << ' ' << sy2[i1] << '\n';
                   return 0;
            }
        }
     }
     puts("-1");
 }


 # include <iostream>
 # include <cstdio>
 # include <cstdlib>
 # include <queue>
 # include <algorithm>
 # define mp make_pair
 # define xx first
 # define yy second

 using namespace std;

 const int N = 1002;

 int dx[] = {N, 1, -1, 0, 0};
 int dy[] = {N, 0, 0, 1, -1};
 int cnt1, cnt2, n, m, d, x[N], y[N], u[N], cnt, M[N][N], cor[N][N];
 int sx[N], sy[N], sx2[N], sy2[N], len, prevcol = -2;
 char a[N][N];

 int bfs(int x1, int y1, int col, bool ok = 1) {
      int c = 0;
      if(a[x1][y1] == 'R' && cor[x1][y1] != prevcol) c ++;
      for (int ww = 1; ww <= x[0]; ++ww)
      if(x[ww] == x1 && y[ww] == y1) {
          u[ww] = col;
          break;
      }
      queue < pair <int, int> > Q, Q2;
      M[x1][y1] = col;
      Q.push(mp(x1, y1));
      if(!ok && col == 1) {
             sx[0] ++;
             sx[sx[0]] = x1; sy[sx[0]] = y1;
      }
      if(!ok && col > 1) {
             sx2[0] ++;
             sx2[sx2[0]] = x1;
             sy2[sx2[0]] = y1;
      }

      for (int i = 1; i <= d; ++i) {
          Q2 = Q;
          while(!Q.empty()) Q.pop();
          while (!Q2.empty()) {
                pair <int, int> t = Q2.front();
                for (int k = 1; k <= 4; ++k) {
                    int cx = t.xx + dx[k];
                    int cy = t.yy + dy[k];
                    if(cx >= 1 && cx <= n && cy >= 1 && cy <= m)
                    if(M[cx][cy] != col && a[cx][cy] != 'X') {
                        if(!ok && col == 1) { sx[0] ++; sx[sx[0]] = cx; sy[sx[0]] = cy; }
                        else if(!ok) { sx2[0] ++; sx2[sx2[0]] = cx; sy2[sx2[0]] = cy; }
                        if(a[cx][cy] == 'R') {
                            if(col == prevcol) cor[cx][cy] = prevcol;
                            if(cor[cx][cy] != prevcol || col == prevcol) c ++;
                            for (int ww = 1; ww <= x[0]; ++ww)
                            if(x[ww] == cx && y[ww] == cy) {
                               u[ww] = col;
                               break;
                            }
                        }
                        M[cx][cy] = col;
                        Q.push(mp(cx, cy));
                    }
                }
                Q2.pop();
          }
      }

      return c;
 }

 int main () {

     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);

     scanf("%d%d%d", &n, &m, &d);

     for (int i = 1; i <= n; ++i)
         for (int j = 1; j <= m; ++j) {
             cin >> a[i][j];
             if(a[i][j] == 'R') {
               ++x[0]; x[x[0]] = i; y[x[0]] = j;
             }
         }

     u[1] = 1;
     cnt1 = bfs(x[1], y[1], ++cnt, 0);

     for (int rr = 1; rr <= sx[0]; ++rr) {
        prevcol = ++cnt;

        cnt1 = bfs(sx[rr], sy[rr], cnt);

        for (int ii = 1; ii <= x[0]; ++ii) {
           if(u[ii] != cnt) {
               sx2[0] = 0;
               cnt2 = bfs(x[ii], y[ii], ++cnt, 0);
               break;
           }
        }
        for (int i1 = 1; i1 <= sx2[0]; ++i1) {
            cnt2 = bfs(sx2[i1], sy2[i1], ++cnt);
            /*if(sx[rr] == 2 && sy[rr] == 3 && sx2[i1] == 6 && sy2[i1] == 9) {
            for (int i = 1; i <= n; ++i) {
                          for (int j = 1; j <= m; ++j) {
                              cout << M[i][j] << ' ';
                          }
                          cout << endl;
                      }
                      cout << prevcol << endl;
                      cout << cnt1  << ' ' << cnt2 << endl;
            }*/
            if(cnt1 + cnt2 == x[0]) {
                    //cout << cnt1 << ' ' << cnt2 << ' ' << prevcol << '\n';

                   cout << sx[rr] << ' ' << sy[rr] << ' ' << sx2[i1] << ' ' << sy2[i1] << '\n';
                   return 0;
            }
        }
     }
     puts("-1");
 }


 # include <iostream>
 # include <cstdio>
 # include <cstdlib>
 # include <queue>
 # include <algorithm>
 # define mp make_pair
 # define xx first
 # define yy second

 using namespace std;

 const int N = 1002;

 int dx[] = {N, 1, -1, 0, 0};
 int dy[] = {N, 0, 0, 1, -1};
 int cnt1, cnt2, n, m, d, x[N], y[N], u[N], cnt, M[N][N];
 int sx[N], sy[N], sx2[N], sy2[N], len;
 char a[N][N];

 int bfs(int x1, int y1, int col, bool ok = 1) {
      int c = 0;
      if(a[x1][y1] == 'R') c ++;
      for (int ww = 1; ww <= x[0]; ++ww)
      if(x[ww] == x1 && y[ww] == y1) {
          u[ww] = col;
          break;
      }
      queue < pair <int, int> > Q, Q2;
      M[x1][y1] = col;
      Q.push(mp(x1, y1));
      if(!ok && col == 1) {
             sx[0] ++;
             sx[sx[0]] = x1; sy[sx[0]] = y1;
      }
      if(!ok && col > 1) {
             sx2[0] ++;
             sx2[sx2[0]] = x1;
             sy2[sx2[0]] = y1;
      }

      for (int i = 1; i <= d; ++i) {
          Q2 = Q;
          while(!Q.empty()) Q.pop();
          while (!Q2.empty()) {
                pair <int, int> t = Q2.front();
                for (int k = 1; k <= 4; ++k) {
                    int cx = t.xx + dx[k];
                    int cy = t.yy + dy[k];
                    if(cx >= 1 && cx <= n && cy >= 1 && cy <= m)
                    if(M[cx][cy] != col && a[cx][cy] != 'X') {
                        M[cx][cy] = col;
                        if(!ok && col == 1) { sx[0] ++; sx[sx[0]] = cx; sy[sx[0]] = cy; }
                        else if(!ok) { sx2[0] ++; sx2[sx2[0]] = cx; sy2[sx2[0]] = cy; }
                        if(a[cx][cy] == 'R') {
                            c ++;
                            for (int ww = 1; ww <= x[0]; ++ww)
                            if(x[ww] == cx && y[ww] == cy) {
                               u[ww] = col;
                               break;
                            }
                        }
                        Q.push(mp(cx, cy));
                    }
                }
                Q2.pop();
          }
      }

      return c;
 }

 int main () {

     scanf("%d%d%d", &n, &m, &d);

     for (int i = 1; i <= n; ++i)
         for (int j = 1; j <= m; ++j) {
             cin >> a[i][j];
             if(a[i][j] == 'R') ++x[0], x[x[0]] = i, y[x[0]] = j;
         }

     u[1] = 1;
     cnt1 = bfs(x[1], y[1], ++cnt, 0);

     for (int rr = 1; rr <= sx[0]; ++rr) {
        cnt1 = bfs(sx[rr], sy[rr], ++cnt);

        if(cnt1 == x[0]) {
                cout << sx[rr] << ' ' << sy[rr] << ' ' << sx[rr] << ' ' << sy[rr] << '\n';
                return 0;
        }
        for (int ii = 1; ii <= x[0]; ++ii) {
           if(u[ii] != cnt) {
               sx2[0] = 0;
               cnt2 = bfs(x[ii], y[ii], ++cnt, 0);
               break;
           }
        }
        for (int i1 = 1; i1 <= sx2[0]; ++i1) {
            cnt2 = bfs(sx2[i1], sy2[i1], ++cnt);
            if(cnt1 + cnt2 == x[0]) {
                   cout << sx[rr] << ' ' << sy[rr] << ' ' << sx2[i1] << ' ' << sy2[i1] << '\n';
                   return 0;
            }
        }
     }

     puts("-1");
 }


 # include <iostream>
 # include <cstdio>
 # include <cstdlib>
 # include <queue>
 # include <algorithm>
 # define mp make_pair
 # define xx first
 # define yy second

 using namespace std;

 const int N = 1002;

 int dx[] = {N, 1, -1, 0, 0};
 int dy[] = {N, 0, 0, 1, -1};
 int cnt1, cnt2, n, m, d, x[N], y[N], u[N], cnt, M[N][N];
 int sx[N], sy[N], sx2[N], sy2[N], len;
 char a[N][N];

 int bfs(int x1, int y1, int col, bool ok = 1) {
      int c = 0;
      if(a[x1][y1] == 'R') c ++;
      for (int ww = 1; ww <= x[0]; ++ww)
      if(x[ww] == x1 && y[ww] == y1) {
          u[ww] = col;
          break;
      }
      queue < pair <int, int> > Q, Q2;
      M[x1][y1] = col;
      Q.push(mp(x1, y1));
      if(!ok && col == 1) {
             sx[0] ++;
             sx[sx[0]] = x1; sy[sx[0]] = y1;
      }
      if(!ok && col > 1) {
             sx2[0] ++;
             sx2[sx2[0]] = x1;
             sy2[sx2[0]] = y1;
      }

      for (int i = 1; i <= d; ++i) {
          Q2 = Q;
          while(!Q.empty()) Q.pop();
          while (!Q2.empty()) {
                pair <int, int> t = Q2.front();
                for (int k = 1; k <= 4; ++k) {
                    int cx = t.xx + dx[k];
                    int cy = t.yy + dy[k];
                    if(cx >= 1 && cx <= n && cy >= 1 && cy <= m)
                    if(M[cx][cy] != col && a[cx][cy] != 'X') {
                        M[cx][cy] = col;
                        if(!ok && col == 1) { sx[0] ++; sx[sx[0]] = cx; sy[sx[0]] = cy; }
                        else if(!ok) { sx2[0] ++; sx2[sx2[0]] = cx; sy2[sx2[0]] = cy; }
                        if(a[cx][cy] == 'R') {
                            c ++;
                            for (int ww = 1; ww <= x[0]; ++ww)
                            if(x[ww] == cx && y[ww] == cy) {
                               u[ww] = col;
                               break;
                            }
                        }
                        Q.push(mp(cx, cy));
                    }
                }
                Q2.pop();
          }
      }

      return c;
 }

 int main () {

     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);

     scanf("%d%d%d", &n, &m, &d);

     for (int i = 1; i <= n; ++i)
         for (int j = 1; j <= m; ++j) {
             cin >> a[i][j];
             if(a[i][j] == 'R') ++x[0], x[x[0]] = i, y[x[0]] = j;
         }

     u[1] = 1;
     cnt1 = bfs(x[1], y[1], ++cnt, 0);

     for (int rr = 1; rr <= sx[0]; ++rr) {
        cnt1 = bfs(sx[rr], sy[rr], ++cnt);

        if(cnt1 == x[0]) {
                cout << sx[rr] << ' ' << sy[rr] << ' ' << sx[rr] << ' ' << sy[rr] << '\n';
                return 0;
        }
        for (int ii = 1; ii <= x[0]; ++ii) {
           if(u[ii] != cnt) {
               sx2[0] = 0;
               cnt2 = bfs(x[ii], y[ii], ++cnt, 0);
               break;
           }
        }
        for (int i1 = 1; i1 <= sx2[0]; ++i1) {
            cnt2 = bfs(sx2[i1], sy2[i1], ++cnt);
            if(cnt1 + cnt2 == x[0]) {
                   cout << sx[rr] << ' ' << sy[rr] << ' ' << sx2[i1] << ' ' << sy2[i1] << '\n';
                   return 0;
            }
        }
     }
     puts("-1");
 }


 # include <iostream>
 # include <cstdio>
 # include <cstdlib>
 # include <queue>
 # include <algorithm>
 # define mp make_pair
 # define xx first
 # define yy second

 using namespace std;

 const int N = 1002;

 int dx[] = {N, 1, -1, 0, 0};
 int dy[] = {N, 0, 0, 1, -1};
 int cnt1, cnt2, n, m, d, x[N], y[N], u[N], cnt, M[N][N], cor[N][N];
 int sx[N], sy[N], sx2[N], sy2[N], len, prevcol = -2;
 char a[N][N];

 int bfs(int x1, int y1, int col, bool ok = 1) {
      int c = 0;
      if(a[x1][y1] == 'R' && (col == prevcol)) c ++;
      else if(a[x1][y1] == 'R' && cor[x1][y1] != prevcol) c ++;
      if(col == prevcol && a[x1][y1] == 'R') cor[x1][y1] = col;

      for (int ww = 1; ww <= x[0]; ++ww)
      if(x[ww] == x1 && y[ww] == y1) {
          u[ww] = col;
          break;
      }
      queue < pair <int, int> > Q, Q2;
      M[x1][y1] = col;
      Q.push(mp(x1, y1));
      if(!ok && col == 1) {
             sx[0] ++;
             sx[sx[0]] = x1; sy[sx[0]] = y1;
      }
      if(!ok && col > 1) {
             sx2[0] ++;
             sx2[sx2[0]] = x1;
             sy2[sx2[0]] = y1;
      }

      for (int i = 1; i <= d; ++i) {
          Q2 = Q;
          while(!Q.empty()) Q.pop();
          while (!Q2.empty()) {
                pair <int, int> t = Q2.front();
                for (int k = 1; k <= 4; ++k) {
                    int cx = t.xx + dx[k];
                    int cy = t.yy + dy[k];
                    if(cx >= 1 && cx <= n && cy >= 1 && cy <= m)
                    if(M[cx][cy] != col && a[cx][cy] != 'X') {
                        if(!ok && col == 1) { sx[0] ++; sx[sx[0]] = cx; sy[sx[0]] = cy; }
                        else if(!ok) { sx2[0] ++; sx2[sx2[0]] = cx; sy2[sx2[0]] = cy; }
                        if(a[cx][cy] == 'R') {
                            if((cor[cx][cy] != prevcol && col != prevcol) || col == prevcol) c ++;
                            if(col == prevcol) cor[cx][cy] = col;
                            for (int ww = 1; ww <= x[0]; ++ww)
                            if(x[ww] == cx && y[ww] == cy) {
                               u[ww] = col;
                               break;
                            }
                        }
                        M[cx][cy] = col;
                        Q.push(mp(cx, cy));
                    }
                }
                Q2.pop();
          }
      }

      return c;
 }

 int main () {

     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);

     scanf("%d%d%d", &n, &m, &d);

     for (int i = 1; i <= n; ++i)
         for (int j = 1; j <= m; ++j) {
             cin >> a[i][j];
             if(a[i][j] == 'R') {
               ++x[0]; x[x[0]] = i; y[x[0]] = j;
             }
         }

     u[1] = 1;
     cnt1 = bfs(x[1], y[1], ++cnt, 0);

     for (int rr = 1; rr <= sx[0]; ++rr) {
        prevcol = ++cnt;

        cnt1 = bfs(sx[rr], sy[rr], cnt);

        for (int ii = 1; ii <= x[0]; ++ii) {
           if(u[ii] != cnt) {
               sx2[0] = 0;
               cnt2 = bfs(x[ii], y[ii], ++cnt, 0);
               break;
           }
        }
        for (int i1 = 1; i1 <= sx2[0]; ++i1) {
            cnt2 = bfs(sx2[i1], sy2[i1], ++cnt);

           // if(sx2[i1] == 6 && sy2[i1] == 6) cout << cnt2 << endl;
            if(cnt1 + cnt2 == x[0]) {
                    //cout << cnt << endl;
                    //cout << x[0] << ' ' << cnt1 << ' ' << cnt2 << endl;
                    //cout << cnt1 << ' ' << cnt2 << ' ' << prevcol << '\n';
                    /*for (int i = 1; i <= n; ++i) {
                          for (int j = 1; j <= m; ++j) {
                              cout << M[i][j] << ' ';
                          }
                          cout << endl;
                    }*/
                   cout << sx[rr] << ' ' << sy[rr] << ' ' << sx2[i1] << ' ' << sy2[i1] << '\n';
                   return 0;
            }
        }
     }
     puts("-1");
 }


 # include <iostream>
 # include <cstdio>
 # include <cstdlib>
 # include <queue>
 # include <algorithm>
 # define mp make_pair
 # define xx first
 # define yy second

 using namespace std;

 const int N = 1002;

 int dx[] = {N, 1, -1, 0, 0};
 int dy[] = {N, 0, 0, 1, -1};
 int cnt1, cnt2, n, m, d, x[N], y[N], u[N], cnt, M[N][N], cor[N][N];
 int sx[N], sy[N], sx2[N], sy2[N], len, prevcol = -2;
 char a[N][N];

 int bfs(int x1, int y1, int col, bool ok = 1) {
      int c = 0;
      if(a[x1][y1] == 'R' && (col == prevcol)) c ++;
      else if(a[x1][y1] == 'R' && cor[x1][y1] != prevcol) c ++;
      if(col == prevcol && a[x1][y1] == 'R') cor[x1][y1] = col;

      for (int ww = 1; ww <= x[0]; ++ww)
      if(x[ww] == x1 && y[ww] == y1) {
          u[ww] = col;
          break;
      }
      queue < pair <int, int> > Q, Q2;
      M[x1][y1] = col;
      Q.push(mp(x1, y1));
      if(!ok && col == 1) {
             sx[0] ++;
             sx[sx[0]] = x1; sy[sx[0]] = y1;
      }
      if(!ok && col > 1) {
             sx2[0] ++;
             sx2[sx2[0]] = x1;
             sy2[sx2[0]] = y1;
      }

      for (int i = 1; i <= d; ++i) {
          Q2 = Q;
          while(!Q.empty()) Q.pop();
          while (!Q2.empty()) {
                pair <int, int> t = Q2.front();
                for (int k = 1; k <= 4; ++k) {
                    int cx = t.xx + dx[k];
                    int cy = t.yy + dy[k];
                    if(cx >= 1 && cx <= n && cy >= 1 && cy <= m)
                    if(M[cx][cy] != col && a[cx][cy] != 'X') {
                        if(!ok && col == 1) { sx[0] ++; sx[sx[0]] = cx; sy[sx[0]] = cy; }
                        else if(!ok) { sx2[0] ++; sx2[sx2[0]] = cx; sy2[sx2[0]] = cy; }
                        if(a[cx][cy] == 'R') {
                            if((cor[cx][cy] != prevcol && col != prevcol) || col == prevcol) c ++;
                            if(col == prevcol) cor[cx][cy] = col;
                            for (int ww = 1; ww <= x[0]; ++ww)
                            if(x[ww] == cx && y[ww] == cy) {
                               u[ww] = col;
                               break;
                            }
                        }
                        M[cx][cy] = col;
                        Q.push(mp(cx, cy));
                    }
                }
                Q2.pop();
          }
      }

      return c;
 }

 int main () {

     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);

     scanf("%d%d%d", &n, &m, &d);

     for (int i = 1; i <= n; ++i)
         for (int j = 1; j <= m; ++j) {
             cin >> a[i][j];
             if(a[i][j] == 'R') {
               ++x[0]; x[x[0]] = i; y[x[0]] = j;
             }
         }

     u[1] = 1;
     cnt1 = bfs(x[1], y[1], ++cnt, 0);

     for (int rr = 1; rr <= sx[0]; ++rr) {
        prevcol = ++cnt;

        cnt1 = bfs(sx[rr], sy[rr], cnt);

        if(cnt1 == x[0]) {
                for (int i = 1; i <= n; ++i) {
                    for (int j = 1; j <= m; ++j) {
                        if(i != sx[rr] && j != sy[rr] && a[i][j] != 'X') {
                             cout << i << ' ' << j << ' ' << sx[rr] << ' ' << sy[rr] << endl;
                             return 0;
                        }
                    }
                }
        }

        for (int ii = 1; ii <= x[0]; ++ii) {
           if(u[ii] != cnt) {
               sx2[0] = 0;
               cnt2 = bfs(x[ii], y[ii], ++cnt, 0);
               break;
           }
        }

        for (int i1 = 1; i1 <= sx2[0]; ++i1) {
            cnt2 = bfs(sx2[i1], sy2[i1], ++cnt);

           // if(sx2[i1] == 6 && sy2[i1] == 6) cout << cnt2 << endl;
            if(cnt1 + cnt2 == x[0]) {
                    //cout << cnt << endl;
                    //cout << x[0] << ' ' << cnt1 << ' ' << cnt2 << endl;
                    //cout << cnt1 << ' ' << cnt2 << ' ' << prevcol << '\n';
                    /*for (int i = 1; i <= n; ++i) {
                          for (int j = 1; j <= m; ++j) {
                              cout << M[i][j] << ' ';
                          }
                          cout << endl;
                    }*/
                   cout << sx[rr] << ' ' << sy[rr] << ' ' << sx2[i1] << ' ' << sy2[i1] << '\n';
                   return 0;
            }
        }
     }
     puts("-1");
 }


 # include <iostream>
 # include <cstdio>
 # include <cstdlib>
 # include <queue>
 # include <algorithm>
 # define mp make_pair
 # define xx first
 # define yy second

 using namespace std;

 const int N = 1002;

 int dx[] = {N, 1, -1, 0, 0};
 int dy[] = {N, 0, 0, 1, -1};
 int cnt1, cnt2, n, m, d, x[N], y[N], u[N], cnt, M[N][N], cor[N][N];
 int sx[N], sy[N], sx2[N], sy2[N], len, prevcol = -2;
 char a[N][N];

 int bfs(int x1, int y1, int col, bool ok = 1) {
      int c = 0;
      if(a[x1][y1] == 'R' && (col == prevcol)) c ++;
      else if(a[x1][y1] == 'R' && cor[x1][y1] != prevcol) c ++;
      if(col == prevcol && a[x1][y1] == 'R') cor[x1][y1] = col;

      for (int ww = 1; ww <= x[0]; ++ww)
      if(x[ww] == x1 && y[ww] == y1) {
          u[ww] = col;
          break;
      }
      queue < pair <int, int> > Q, Q2;
      M[x1][y1] = col;
      Q.push(mp(x1, y1));
      if(!ok && col == 1) {
             sx[0] ++;
             sx[sx[0]] = x1; sy[sx[0]] = y1;
      }
      if(!ok && col > 1) {
             sx2[0] ++;
             sx2[sx2[0]] = x1;
             sy2[sx2[0]] = y1;
      }

      for (int i = 1; i <= d; ++i) {
          Q2 = Q;
          while(!Q.empty()) Q.pop();
          while (!Q2.empty()) {
                pair <int, int> t = Q2.front();
                for (int k = 1; k <= 4; ++k) {
                    int cx = t.xx + dx[k];
                    int cy = t.yy + dy[k];
                    if(cx >= 1 && cx <= n && cy >= 1 && cy <= m)
                    if(M[cx][cy] != col && a[cx][cy] != 'X') {
                        if(!ok && col == 1) { sx[0] ++; sx[sx[0]] = cx; sy[sx[0]] = cy; }
                        else if(!ok) { sx2[0] ++; sx2[sx2[0]] = cx; sy2[sx2[0]] = cy; }
                        if(a[cx][cy] == 'R') {
                            if((cor[cx][cy] != prevcol && col != prevcol) || col == prevcol) c ++;
                            if(col == prevcol) cor[cx][cy] = col;
                            for (int ww = 1; ww <= x[0]; ++ww)
                            if(x[ww] == cx && y[ww] == cy) {
                               u[ww] = col;
                               break;
                            }
                        }
                        M[cx][cy] = col;
                        Q.push(mp(cx, cy));
                    }
                }
                Q2.pop();
          }
      }

      return c;
 }

 int main () {

     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);

     scanf("%d%d%d", &n, &m, &d);

     for (int i = 1; i <= n; ++i)
         for (int j = 1; j <= m; ++j) {
             cin >> a[i][j];
             if(a[i][j] == 'R') {
               ++x[0]; x[x[0]] = i; y[x[0]] = j;
             }
         }

     u[1] = 1;
     cnt1 = bfs(x[1], y[1], ++cnt, 0);

     for (int rr = 1; rr <= sx[0]; ++rr) {
        prevcol = ++cnt;

        cnt1 = bfs(sx[rr], sy[rr], cnt);

        if(cnt1 == x[0]) {
                for (int i = 1; i <= n; ++i) {
                    for (int j = 1; j <= m; ++j) {
                        if(i != sx[rr] && j != sy[rr] && a[i][j] != 'X') {
                             cout << i << ' ' << j << ' ' << sx[rr] << ' ' << sy[rr] << endl;
                             return 0;
                        }
                    }
                }
        }

        for (int ii = 1; ii <= x[0]; ++ii) {
           if(u[ii] != cnt) {
               sx2[0] = 0;
               cnt2 = bfs(x[ii], y[ii], ++cnt, 0);
               break;
           }
        }

        for (int i1 = 1; i1 <= sx2[0]; ++i1) {
            cnt2 = bfs(sx2[i1], sy2[i1], ++cnt);
            if(cnt1 + cnt2 == x[0]) {
                   cout << sx[rr] << ' ' << sy[rr] << ' ' << sx2[i1] << ' ' << sy2[i1] << '\n';
                   return 0;
            }
        }
     }
     puts("-1");
 }


 # include <iostream>
 # include <cstdio>
 # include <cstdlib>
 # include <queue>
 # include <algorithm>
 # define mp make_pair
 # define xx first
 # define yy second

 using namespace std;

 const int N = 1002;

 int dx[] = {N, 1, -1, 0, 0};
 int dy[] = {N, 0, 0, 1, -1};
 int cnt1, cnt2, n, m, d, x[N], y[N], u[N], cnt, M[N][N], cor[N][N];
 int sx[N], sy[N], sx2[N], sy2[N], len, prevcol = -2;
 char a[N][N];

 int bfs(int x1, int y1, int col, bool ok = 1) {
      int c = 0;
      if(a[x1][y1] == 'R' && cor[x1][y1] != prevcol) c ++;
      for (int ww = 1; ww <= x[0]; ++ww)
      if(x[ww] == x1 && y[ww] == y1) {
          u[ww] = col;
          break;
      }
      queue < pair <int, int> > Q, Q2;
      M[x1][y1] = col;
      Q.push(mp(x1, y1));
      if(!ok && col == 1) {
             sx[0] ++;
             sx[sx[0]] = x1; sy[sx[0]] = y1;
      }
      if(!ok && col > 1) {
             sx2[0] ++;
             sx2[sx2[0]] = x1;
             sy2[sx2[0]] = y1;
      }

      for (int i = 1; i <= d; ++i) {
          Q2 = Q;
          while(!Q.empty()) Q.pop();
          while (!Q2.empty()) {
                pair <int, int> t = Q2.front();
                for (int k = 1; k <= 4; ++k) {
                    int cx = t.xx + dx[k];
                    int cy = t.yy + dy[k];
                    if(cx >= 1 && cx <= n && cy >= 1 && cy <= m)
                    if(M[cx][cy] != col && a[cx][cy] != 'X') {
                        if(!ok && col == 1) { sx[0] ++; sx[sx[0]] = cx; sy[sx[0]] = cy; }
                        else if(!ok) { sx2[0] ++; sx2[sx2[0]] = cx; sy2[sx2[0]] = cy; }
                        if(a[cx][cy] == 'R') {
                            if(col == prevcol) cor[cx][cy] = prevcol;
                            if(cor[cx][cy] != prevcol || col == prevcol) c ++;
                            for (int ww = 1; ww <= x[0]; ++ww)
                            if(x[ww] == cx && y[ww] == cy) {
                               u[ww] = col;
                               break;
                            }
                        }
                        M[cx][cy] = col;
                        Q.push(mp(cx, cy));
                    }
                }
                Q2.pop();
          }
      }

      return c;
 }

 int main () {

     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);

     scanf("%d%d%d", &n, &m, &d);

     for (int i = 1; i <= n; ++i)
         for (int j = 1; j <= m; ++j) {
             cin >> a[i][j];
             if(a[i][j] == 'R') {
               ++x[0]; x[x[0]] = i; y[x[0]] = j;
             }
         }

     u[1] = 1;
     cnt1 = bfs(x[1], y[1], ++cnt, 0);

     for (int rr = 1; rr <= sx[0]; ++rr) {
        prevcol = ++cnt;

        cnt1 = bfs(sx[rr], sy[rr], cnt);

        if(cnt1 == x[0]) {
                cout << sx[rr] << ' ' << sy[rr] << ' ' << sx[rr] << ' ' << sy[rr] << '\n';
                return 0;
        }
        for (int ii = 1; ii <= x[0]; ++ii) {
           if(u[ii] != cnt) {
               sx2[0] = 0;
               cnt2 = bfs(x[ii], y[ii], ++cnt, 0);
               break;
           }
        }
        for (int i1 = 1; i1 <= sx2[0]; ++i1) {
            cnt2 = bfs(sx2[i1], sy2[i1], ++cnt);
            /*if(sx[rr] == 2 && sy[rr] == 3 && sx2[i1] == 6 && sy2[i1] == 9) {
            for (int i = 1; i <= n; ++i) {
                          for (int j = 1; j <= m; ++j) {
                              cout << M[i][j] << ' ';
                          }
                          cout << endl;
                      }
                      cout << prevcol << endl;
                      cout << cnt1  << ' ' << cnt2 << endl;
            }*/
            if(cnt1 + cnt2 == x[0]) {
                    //cout << cnt1 << ' ' << cnt2 << ' ' << prevcol << '\n';

                   cout << sx[rr] << ' ' << sy[rr] << ' ' << sx2[i1] << ' ' << sy2[i1] << '\n';
                   return 0;
            }
        }
     }
     puts("-1");
 }


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
#include<string>
#include<set>
#define LL long long
#define fi first
#define se second
#define MP make_pair
#define PII pair<int,int>
using namespace std;
int n,m,D,A,vis[1010][1010],dis[1010][1010],tot,num[1010][1010],xx[4]={1,-1,0,0},yy[4]={0,0,1,-1};
bool bro[1010][1010];
char s[1010][1010];
PII p[1000010];
queue<PII> h;
vector<PII> Q;
void read(int &x)
{
	char ch=getchar();int mark=1;for(;ch!='-'&&(ch<'0'||ch>'9');ch=getchar());if (ch=='-') mark=-1,ch=getchar();
	for(x=0;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-48;x*=mark;
}
bool check(int x,int y,bool f2) {return vis[x][y]!=A-f2&&s[x][y]=='R';}
int bfs(bool f1,bool f2,PII st)
{
	h.push(st);dis[st.fi][st.se]=D;
	int ans=0;A++;
	ans+=check(st.fi,st.se,f2);
	vis[st.fi][st.se]=A;
	while (h.size())
	{
		int x=h.front().fi,y=h.front().se;h.pop();
		if (dis[x][y]==0)
		{
			if (f1) bro[x][y]=1;
			continue;
		}
		for(int i=0;i<4;i++)
		{
			int x1=x+xx[i],y1=y+yy[i];
			if (s[x1][y1]!='X'&&vis[x1][y1]!=A)
			{
				dis[x1][y1]=dis[x][y]-1;
				ans+=check(x1,y1,f2);
				vis[x1][y1]=A;
				h.push(MP(x1,y1));
			}
		}
	}
	return ans;
}
PII Other(int x,int y)
{
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if (s[i][j]!='X'&&(i!=x||j!=y)) return MP(i,j);
}
int main()
{
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	read(n);read(m);read(D);
	for(int i=1;i<=n;i++) scanf("%s",s[i]+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if (s[i][j]=='R') p[++tot]=MP(i,j),num[i][j]=tot;
	if (tot>2*(D*D+(D+1)*(D+1)))
	{
		printf("-1\n");return 0;
	}
	for(int i=1;i<=tot;i++) bfs(1,0,p[i]);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if (bro[i][j])
			{
				Q.push_back(MP(i,j));
				if (bfs(0,0,MP(i,j))==tot)
				{
					PII tmp=Other(i,j);
					printf("%d %d %d %d\n",i,j,tmp.fi,tmp.se);
					return 0;
				}
			}
	for(int i=0;i<Q.size();i++)
		for(int j=i+1;j<Q.size();j++)
			if (bfs(0,0,Q[i])+bfs(0,1,Q[j])==tot)
			{
				printf("%d %d %d %d\n",Q[i].fi,Q[i].se,Q[j].fi,Q[j].se);return 0;
			}
	printf("-1\n");
	return 0;
}