#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#define _CRT_SECURE_NO_WARNINGS
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_map>
# include <unordered_set>

//#ifdef LOCAL
//# include <opencv2/core/core.hpp>
//# include <opencv2/highgui/highgui.hpp>
//# include <opencv2/imgproc/imgproc.hpp>
//#endif

using namespace std;

#define VA_NUM_ARGS(...) VA_NUM_ARGS_IMPL_((0,__VA_ARGS__, 6,5,4,3,2,1))
#define VA_NUM_ARGS_IMPL_(tuple) VA_NUM_ARGS_IMPL tuple
#define VA_NUM_ARGS_IMPL(_0,_1,_2,_3,_4,_5,_6,N,...) N
#define macro_dispatcher(macro, ...) macro_dispatcher_(macro, VA_NUM_ARGS(__VA_ARGS__))
#define macro_dispatcher_(macro, nargs) macro_dispatcher__(macro, nargs)
#define macro_dispatcher__(macro, nargs) macro_dispatcher___(macro, nargs)
#define macro_dispatcher___(macro, nargs) macro ## nargs
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define DBN(...) macro_dispatcher(DBN, __VA_ARGS__)(__VA_ARGS__)
#define DA(a,n) cerr<<#a<<"=["; printarray(a,n); cerr<<"]\n"
#define DAR(a,n,s) cerr<<#a<<"["<<s<<"-"<<n-1<<"]=["; printarray(a,n,s); cerr<<"]\n"

#ifdef _MSC_VER
#define PREFETCH(ptr, rw, level) ((void)0)
#else
#define PREFETCH(ptr, rw, level) __builtin_prefetch(ptr, rw, level)
#endif

#if defined _MSC_VER
#define ASSUME(condition) ((void)0)
#define __restrict
#elif defined __clang__
#define ASSUME(condition)       __builtin_assume(condition)
#elif defined __GNUC__
[[noreturn]] __attribute__((always_inline)) inline void undefinedBehaviour() {}
#define ASSUME(condition)       ((condition) ? true : (undefinedBehaviour(), false))
#endif

#ifdef LOCAL
#define CURTIME() cerr << clock() * 1.0 / CLOCKS_PER_SEC << endl
#else
#define CURTIME()
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef int itn;

template<class T1, class T2, class T3>
struct triple{ T1 a; T2 b; T3 c; triple() : a(T1()), b(T2()), c(T3()) {}; triple(T1 _a, T2 _b, T3 _c) :a(_a), b(_b), c(_c){} };
template<class T1, class T2, class T3>
bool operator<(const triple<T1,T2,T3>&t1,const triple<T1,T2,T3>&t2){if(t1.a!=t2.a)return t1.a<t2.a;else if(t1.b!=t2.b)return t1.b<t2.b;else return t1.c<t2.c;}
template<class T1, class T2, class T3>
bool operator>(const triple<T1,T2,T3>&t1,const triple<T1,T2,T3>&t2){if(t1.a!=t2.a)return t1.a>t2.a;else if(t1.b!=t2.b)return t1.b>t2.b;else return t1.c>t2.c;}
#define tri triple<int,int,int>
#define trll triple<ll,ll,ll>

#define FI(n) for(int i=0;i<(n);++i)
#define FJ(n) for(int j=0;j<(n);++j)
#define FK(n) for(int k=0;k<(n);++k)
#define FL(n) for(int l=0;l<(n);++l)
#define FQ(n) for(int q=0;q<(n);++q)
#define FOR(i,a,b) for(int i = (a), __e = (int) (b); i < __e; ++i)
#define all(a) std::begin(a), std::end(a)
#define reunique(v) v.resize(std::unique(v.begin(), v.end()) - v.begin())

#define sqr(x) ((x) * (x))
#define sqrt(x) sqrt(1.0 * (x))
#define pow(x, n) pow(1.0 * (x), n)

#define COMPARE(obj) [&](const std::decay_t<decltype(obj)>& a, const std::decay_t<decltype(obj)>& b)
#define COMPARE_BY(obj, field) [&](const std::decay_t<decltype(obj)>& a, const std::decay_t<decltype(obj)>& b) { return a.field < b.field; }

#define checkbit(n, b) (((n) >> (b)) & 1)
#define setbit(n, b) ((n) | (static_cast<std::decay<decltype(n)>::type>(1) << (b)))
#define removebit(n, b) ((n) & ~(static_cast<std::decay<decltype(n)>::type>(1) << (b)))
#define flipbit(n, b) ((n) ^ (static_cast<std::decay<decltype(n)>::type>(1) << (b)))
inline int countBits(uint v){v=v-((v>>1)&0x55555555);v=(v&0x33333333)+((v>>2)&0x33333333);return((v+(v>>4)&0xF0F0F0F)*0x1010101)>>24;}
inline int countBits(ull v){uint t=v>>32;uint p=(v & ((1ULL << 32) - 1)); return countBits(t) + countBits(p); }
inline int countBits(ll v){return countBits((ull)v); }
inline int countBits(int v){return countBits((uint)v); }
unsigned int reverseBits(uint x){ x = (((x & 0xaaaaaaaa) >> 1) | ((x & 0x55555555) << 1)); x = (((x & 0xcccccccc) >> 2) | ((x & 0x33333333) << 2)); x = (((x & 0xf0f0f0f0) >> 4) | ((x & 0x0f0f0f0f) << 4)); x = (((x & 0xff00ff00) >> 8) | ((x & 0x00ff00ff) << 8)); return((x >> 16) | (x << 16)); }
template<class T> inline int sign(T x){ return x > 0 ? 1 : x < 0 ? -1 : 0; }
inline bool isPowerOfTwo(int x){ return (x != 0 && (x&(x - 1)) == 0); }
constexpr ll power(ll x, int p) { return p == 0 ? 1 : (x * power(x, p - 1)); }
template<class T>
inline bool inRange(const T& val, const T& min, const T& max) { return min <= val && val <= max; }
//template<class T1, class T2, class T3> T1 inline clamp(T1 x, const T2& a, const T3& b) { if (x < a) return a; else if (x > b) return b; else return x; }
unsigned long long rdtsc() { unsigned long long ret = 0;
#ifdef __clang__
    return __builtin_readcyclecounter();
#endif
#ifndef _MSC_VER
    asm volatile("rdtsc" : "=A" (ret) : :);
#endif
    return ret; }
// Fast IO ********************************************************************************************************
const int __BS = 4096;
static char __bur[__BS + 16], *__er = __bur + __BS, *__ir = __er;
template<class T = int> T readInt() {
    auto c = [&]() { if (__ir == __er) std::fill(__bur, __bur + __BS, 0), cin.read(__bur, __BS), __ir = __bur; };
    c(); while (*__ir && (*__ir < '0' || *__ir > '9') && *__ir != '-') ++__ir; c();
    bool m = false; if (*__ir == '-') ++__ir, c(), m = true;
    T r = 0; while (*__ir >= '0' && *__ir <= '9') r = r * 10 + *__ir - '0', ++__ir, c();
    ++__ir; return m ? -r : r;
}
string readString() {
    auto c = [&]() { if (__ir == __er) std::fill(__bur, __bur + __BS, 0), cin.read(__bur, __BS), __ir = __bur; };
    string r; c(); while (*__ir && isspace(*__ir)) ++__ir, c();
    while (!isspace(*__ir)) r.push_back(*__ir), ++__ir, c();
    ++__ir; return r;
}
char readChar() {
    auto c = [&]() { if (__ir == __er) std::fill(__bur, __bur + __BS, 0), cin.read(__bur, __BS), __ir = __bur; };
    c(); while (*__ir && isspace(*__ir)) ++__ir, c(); return *__ir++;
}
static char __buw[__BS + 20], *__iw = __buw, *__ew = __buw + __BS;
template<class T>
void writeInt(T x, char endc = '\n') {
    if (x < 0) *__iw++ = '-', x = -x; if (x == 0) *__iw++ = '0';
    char* s = __iw;
    while (x) { T t = x / 10; char c = x - 10 * t + '0'; *__iw++ = c; x = t; }
    char* f = __iw - 1; while (s < f) swap(*s, *f), ++s, --f;
    if (__iw > __ew) cout.write(__buw, __iw - __buw), __iw = __buw;
    if (endc) { *__iw++ = endc; }
}
template<class T>
void writeStr(const T& str) {
    int i = 0; while (str[i]) { *__iw++ = str[i++]; if (__iw > __ew) cout.write(__buw, __iw - __buw), __iw = __buw; }
}
struct __FL__ { ~__FL__() { if (__iw != __buw) cout.write(__buw, __iw - __buw); } };
static __FL__ __flushVar__;

//STL output *****************************************************************************************************
#define TT1 template<class T>
#define TT1T2 template<class T1, class T2>
#define TT1T2T3 template<class T1, class T2, class T3>
TT1T2 ostream& operator << (ostream& os, const pair<T1, T2>& p);
TT1 ostream& operator << (ostream& os, const vector<T>& v);
TT1T2 ostream& operator << (ostream& os, const set<T1, T2>&v);
TT1T2 ostream& operator << (ostream& os, const multiset<T1, T2>&v);
TT1T2 ostream& operator << (ostream& os, priority_queue<T1, T2> v);
TT1T2T3 ostream& operator << (ostream& os, const map<T1, T2, T3>& v);
TT1T2T3 ostream& operator << (ostream& os, const multimap<T1, T2, T3>& v);
TT1T2T3 ostream& operator << (ostream& os, const triple<T1, T2, T3>& t);
template<class T, size_t N> ostream& operator << (ostream& os, const array<T, N>& v);
TT1T2 ostream& operator << (ostream& os, const pair<T1, T2>& p){ return os <<"("<<p.first<<", "<< p.second<<")"; }
TT1 ostream& operator << (ostream& os, const vector<T>& v){       bool f=1;os<<"[";for(auto& i : v) { if (!f)os << ", ";os<<i;f=0;}return os << "]"; }
template<class T, size_t N> ostream& operator << (ostream& os, const array<T, N>& v) {     bool f=1;os<<"[";for(auto& i : v) { if (!f)os << ", ";os<<i;f=0;}return os << "]"; }
TT1T2 ostream& operator << (ostream& os, const set<T1, T2>&v){    bool f=1;os<<"[";for(auto& i : v) { if (!f)os << ", ";os<<i;f=0;}return os << "]"; }
TT1T2 ostream& operator << (ostream& os, const multiset<T1,T2>&v){bool f=1;os<<"[";for(auto& i : v) { if (!f)os << ", ";os<<i;f=0;}return os << "]"; }
TT1T2T3 ostream& operator << (ostream& os, const map<T1,T2,T3>& v){ bool f = 1; os << "["; for (auto& ii : v) { if (!f)os << ", "; os << "(" << ii.first << " -> " << ii.second << ") "; f = 0; }return os << "]"; }
TT1T2 ostream& operator << (ostream& os, const multimap<T1, T2>& v){ bool f = 1; os << "["; for (auto& ii : v) { if (!f)os << ", "; os << "(" << ii.first << " -> " << ii.second << ") "; f = 0; }return os << "]"; }
TT1T2 ostream& operator << (ostream& os, priority_queue<T1, T2> v) { bool f = 1; os << "["; while (!v.empty()) { auto x = v.top(); v.pop(); if (!f) os << ", "; f = 0; os << x; } return os << "]"; }
TT1T2T3 ostream& operator << (ostream& os, const triple<T1, T2, T3>& t){ return os << "(" << t.a << ", " << t.b << ", " << t.c << ")"; }
TT1T2 void printarray(const T1& a, T2 sz, T2 beg = 0){ for (T2 i = beg; i<sz; i++) cout << a[i] << " "; cout << endl; }

//STL input *****************************************************************************************************
TT1T2T3 inline istream& operator >> (istream& os, triple<T1, T2, T3>& t);
TT1T2 inline istream& operator >> (istream& os, pair<T1, T2>& p) { return os >> p.first >> p.second; }
TT1 inline istream& operator >> (istream& os, vector<T>& v) {
    if (v.size()) for (T& t : v) os >> t; else {
        string s; T obj; while (s.empty()) {getline(os, s); if (!os) return os;}
        stringstream ss(s); while (ss >> obj) v.push_back(obj);
    }
    return os;
}
TT1T2T3 inline istream& operator >> (istream& os, triple<T1, T2, T3>& t) { return os >> t.a >> t.b >> t.c; }

//Pair magic *****************************************************************************************************
#define PT1T2 pair<T1, T2>
TT1T2 inline PT1T2 operator+(const PT1T2 &p1 , const PT1T2 &p2) { return PT1T2(p1.first + p2.first, p1.second + p2.second); }
TT1T2 inline PT1T2& operator+=(PT1T2 &p1 , const PT1T2 &p2) { p1.first += p2.first, p1.second += p2.second; return p1; }
TT1T2 inline PT1T2 operator-(const PT1T2 &p1 , const PT1T2 &p2) { return PT1T2(p1.first - p2.first, p1.second - p2.second); }
TT1T2 inline PT1T2& operator-=(PT1T2 &p1 , const PT1T2 &p2) { p1.first -= p2.first, p1.second -= p2.second; return p1; }

#undef TT1
#undef TT1T2
#undef TT1T2T3

#define FREIN(FILE) freopen(FILE, "rt", stdin)
#define FREOUT(FILE) freopen(FILE, "wt", stdout)
#ifdef LOCAL
#define BEGIN_PROFILE(idx, name) int profileIdx = idx; profileName[profileIdx] = name; totalTime[profileIdx] -= rdtsc() / 1e3;
#define END_PROFILE totalTime[profileIdx] += rdtsc() / 1e3; totalCount[profileIdx]++;
#else
#define BEGIN_PROFILE(idx, name)
#define END_PROFILE
#endif

const int USUAL_MOD = 1000000007;
template<class T> inline void normmod(T &x, T m = USUAL_MOD) { x %= m; if (x < 0) x += m; }
template<class T1, class T2> inline T2 summodfast(T1 x, T1 y, T2 m = USUAL_MOD) { T2 res = x + y; if (res >= m) res -= m; return res; }
template<class T1, class T2, class T3 = int> inline void addmodfast(T1 &x, T2 y, T3 m = USUAL_MOD) { x += y; if (x >= m) x -= m; }
template<class T1, class T2, class T3 = int> inline void submodfast(T1 &x, T2 y, T3 m = USUAL_MOD) { x -= y; if (x < 0) x += m; }
inline ll mulmod(ll x, ll n, ll m){ x %= m; n %= m; ll r = x * n - ll(ld(x)*ld(n) / ld(m)) * m; while (r < 0) r += m; while (r >= m) r -= m; return r; }
inline ll powmod(ll x, ll n, ll m){ ll r = 1; normmod(x, m); while (n){ if (n & 1) r *= x; x *= x; r %= m; x %= m; n /= 2; }return r; }
inline ll powmulmod(ll x, ll n, ll m) { ll res = 1; normmod(x, m); while (n){ if (n & 1)res = mulmod(res, x, m); x = mulmod(x, x, m); n /= 2; } return res; }
template<class T> inline T gcd(T a, T b) { while (b) { T t = a % b; a = b; b = t; } return a; }
template<class T>
T fast_gcd(T u, T v) {
    int shl = 0; while ( u && v && u != v) { T eu = u & 1; u >>= eu ^ 1; T ev = v & 1; v >>= ev ^ 1;
        shl += (~(eu | ev) & 1); T d = u & v & 1 ? (u + v) >> 1 : 0; T dif = (u - v) >> (sizeof(T) * 8 - 1); u -= d & ~dif; v -= d & dif;
    } return std::max(u, v) << shl;
}

inline ll lcm(ll a, ll b){ return a / gcd(a, b) * b; }
template<class T> inline T gcd(T a, T b, T c){ return gcd(gcd(a, b), c); }
ll gcdex(ll a, ll b, ll& x, ll& y) {
    if (!a) { x = 0; y = 1; return b; }
    ll y1; ll d = gcdex(b % a, a, y, y1); x = y1 - (b / a) * y;
    return d;
}

bool isPrime(long long n) {
    if (n <= (1 << 14)) { int x = (int) n; if (x <= 4 || x % 2 == 0 || x % 3 == 0) return x == 2 || x == 3;
        for (int i = 5; i * i <= x; i += 6) if (x % i == 0 || x % (i + 2) == 0) return 0; return 1; }
    long long s = n - 1; int t = 0; while (s % 2 == 0) { s /= 2; ++t; }
    for (int a : {2, 325, 9375, 28178, 450775, 9780504, 1795265022}) { if (!(a %= n)) return true;
        long long f = powmulmod(a, s, n); if (f == 1 || f == n - 1) continue;
        for (int i = 1; i < t; ++i) if ((f = mulmod(f, f, n)) == n - 1) goto nextp;
        return false; nextp:;
    } return true;
}

// Useful constants

//int some_primes[7] = {24443, 100271, 1000003, 1000333, 5000321, 98765431,
#define T9          1000000000
#define T18         1000000000000000000LL
#define INF         1011111111
#define LLINF       1000111000111000111LL
#define mod         1000000007
#define fftmod      998244353
#define EPS         1e-10
#define PI          3.14159265358979323846264
#define link        himomisubmitted
#define rank        thatsnoteasytask
//*************************************************************************************

int32_t solve();
int32_t main(int argc, char** argv) {
    ios_base::sync_with_stdio(0);cin.tie(0);
#ifdef LOCAL
    FREIN("input.txt");
//    FREOUT("out.txt");
#endif
    return solve();
}

//int a[101010];
//bitset<200020> bspos;
//bitset<200020> bsneg;

struct Node {
    Node *lp;
    Node *rp;
};
Node nodes[20202020];
Node* lastn = nodes;
int a[202020];
int b[101010];
bool _used[202020];
bool* used = _used + 100000;
Node *rootpos, *rootneg;
Node *roottmp;
void build(Node*& cur, int l, int r) {
    if (l == r) {
        if (used[l]) {
            cur = lastn++;
        }
    } else {
        int m = (l + r) / 2;
        Node *lp = nullptr;
        Node *rp = nullptr;
        build(lp, l, m);
        build(rp, m + 1, r);
        if (lp || rp) {
            cur = lastn++;
            cur->lp = lp;
            cur->rp = rp;
        }
    }
}
void merge(Node*& from, Node*& to, int l, int r, int x, int y) {
    if (x > r || y < l) return;
    if (!from) return;
    if (x <= l && r <= y) {
        if (!to || l == r) {
            to = from;
        } else {
            int m = (l + r) / 2;
            merge(from->lp, to->lp, l, m, x, y);
            merge(from->rp, to->rp, m + 1, r, x, y);
        }
        from = nullptr;
    } else {
        int m = (l + r) / 2;
        if (!to) {
            to = lastn++;
        }
        merge(from->lp, to->lp, l, m, x, y);
        merge(from->rp, to->rp, m + 1, r, x, y);
        if (from && !from->lp && !from->rp) {
            from = nullptr;
        }
    }
}
bool _res[202002];
bool* res = _res + 100000;
void dfs(Node* cur, int l, int r, int f) {
    if (!cur) return;
    if (l == r) {
        res[l * f] = true;
    } else {
        int m = (l + r) / 2;
        dfs(cur->lp, l, m, f);
        dfs(cur->rp, m + 1, r, f);
    }
}

int solve() {
    mt19937_64 gen(42);
    auto getRand = [&](){
        return std::uniform_int_distribution<int>(-100000, 100000)(gen);
    };
    if (0)
    {
        FREOUT("input.txt");
        cout << endl;
        return 0;
        int n = 100000;
        int q = n;
        cout << n << ' ' << q << endl;
        for (int i = 0; i < n; ++i) {
            cout << getRand() << ' ';
        } cout << endl;
        for (int i = 0; i < q; ++i) {
            cout << (rand() % 2 ? '<' : '>') << ' ' << getRand() << endl;
        }
        return 0;
    }
    int n, q;
    n = readInt();
    q = readInt();
    FI(n) {
        a[i] = readInt();
        used[a[i]] = true;
        b[i] = a[i];
//        a[i] = getRand();
    }
    const int N = 100001;
    build(rootpos, 1, N);
    for (int i = 0; i <= N; ++i) {
        used[i] = used[-i];
    }
    build(rootneg, 1, N);
//    double begin = clock();
    FJ(q) {
        char c = readChar();
        int x = readInt();
//        if (c == '<') {
//            FI(n) {
//                a[i] = a[i] < x ? -a[i] : a[i];
//            }
//        } else {
//            FI(n) {
//                a[i] = a[i] > x ? -a[i] : a[i];
//            }
//        }
        if (c == '>') {
            ++x;
            if (x >= 0) {
                merge(rootpos, rootneg, 1, N, x, N);
            } else {
                merge(rootneg, roottmp, 1, N, 1, -x);
                merge(rootpos, rootneg, 1, N, 1, N);
                merge(roottmp, rootpos, 1, N, 1, N);
            }
        } else {
            --x;
            if (x <= 0) {
                merge(rootneg, rootpos, 1, N, -x, N);
            } else {
                merge(rootpos, roottmp, 1, N, 1, x);
                merge(rootneg, rootpos, 1, N, 1, N);
                merge(roottmp, rootneg, 1, N, 1, N);
            }
        }
        assert(roottmp == nullptr);
    }
    res[0] = used[0];
    dfs(rootpos, 1, N, 1);
    dfs(rootneg, 1, N, -1);
    FI(n) {
        if (!res[b[i]]) {
            b[i] = -b[i];
        }
    }
//    printarray(a, n);
//    printarray(b, n);
    FI(n) {
//        assert(a[i] == b[i]);
        writeInt(b[i], i == n - 1 ? '\n' : ' ');
    }
//    double end = clock();
//    cout << (end - begin) * 1.0 / CLOCKS_PER_SEC << endl;
    return 0;
}


#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#define _CRT_SECURE_NO_WARNINGS
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_map>
# include <unordered_set>

//#ifdef LOCAL
//# include <opencv2/core/core.hpp>
//# include <opencv2/highgui/highgui.hpp>
//# include <opencv2/imgproc/imgproc.hpp>
//#endif

using namespace std;

#define VA_NUM_ARGS(...) VA_NUM_ARGS_IMPL_((0,__VA_ARGS__, 6,5,4,3,2,1))
#define VA_NUM_ARGS_IMPL_(tuple) VA_NUM_ARGS_IMPL tuple
#define VA_NUM_ARGS_IMPL(_0,_1,_2,_3,_4,_5,_6,N,...) N
#define macro_dispatcher(macro, ...) macro_dispatcher_(macro, VA_NUM_ARGS(__VA_ARGS__))
#define macro_dispatcher_(macro, nargs) macro_dispatcher__(macro, nargs)
#define macro_dispatcher__(macro, nargs) macro_dispatcher___(macro, nargs)
#define macro_dispatcher___(macro, nargs) macro ## nargs
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define DBN(...) macro_dispatcher(DBN, __VA_ARGS__)(__VA_ARGS__)
#define DA(a,n) cerr<<#a<<"=["; printarray(a,n); cerr<<"]\n"
#define DAR(a,n,s) cerr<<#a<<"["<<s<<"-"<<n-1<<"]=["; printarray(a,n,s); cerr<<"]\n"

#ifdef _MSC_VER
#define PREFETCH(ptr, rw, level) ((void)0)
#else
#define PREFETCH(ptr, rw, level) __builtin_prefetch(ptr, rw, level)
#endif

#if defined _MSC_VER
#define ASSUME(condition) ((void)0)
#define __restrict
#elif defined __clang__
#define ASSUME(condition)       __builtin_assume(condition)
#elif defined __GNUC__
[[noreturn]] __attribute__((always_inline)) inline void undefinedBehaviour() {}
#define ASSUME(condition)       ((condition) ? true : (undefinedBehaviour(), false))
#endif

#ifdef LOCAL
#define CURTIME() cerr << clock() * 1.0 / CLOCKS_PER_SEC << endl
#else
#define CURTIME()
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef int itn;

template<class T1, class T2, class T3>
struct triple{ T1 a; T2 b; T3 c; triple() : a(T1()), b(T2()), c(T3()) {}; triple(T1 _a, T2 _b, T3 _c) :a(_a), b(_b), c(_c){} };
template<class T1, class T2, class T3>
bool operator<(const triple<T1,T2,T3>&t1,const triple<T1,T2,T3>&t2){if(t1.a!=t2.a)return t1.a<t2.a;else if(t1.b!=t2.b)return t1.b<t2.b;else return t1.c<t2.c;}
template<class T1, class T2, class T3>
bool operator>(const triple<T1,T2,T3>&t1,const triple<T1,T2,T3>&t2){if(t1.a!=t2.a)return t1.a>t2.a;else if(t1.b!=t2.b)return t1.b>t2.b;else return t1.c>t2.c;}
#define tri triple<int,int,int>
#define trll triple<ll,ll,ll>

#define FI(n) for(int i=0;i<(n);++i)
#define FJ(n) for(int j=0;j<(n);++j)
#define FK(n) for(int k=0;k<(n);++k)
#define FL(n) for(int l=0;l<(n);++l)
#define FQ(n) for(int q=0;q<(n);++q)
#define FOR(i,a,b) for(int i = (a), __e = (int) (b); i < __e; ++i)
#define all(a) std::begin(a), std::end(a)
#define reunique(v) v.resize(std::unique(v.begin(), v.end()) - v.begin())

#define sqr(x) ((x) * (x))
#define sqrt(x) sqrt(1.0 * (x))
#define pow(x, n) pow(1.0 * (x), n)

#define COMPARE(obj) [&](const std::decay_t<decltype(obj)>& a, const std::decay_t<decltype(obj)>& b)
#define COMPARE_BY(obj, field) [&](const std::decay_t<decltype(obj)>& a, const std::decay_t<decltype(obj)>& b) { return a.field < b.field; }

#define checkbit(n, b) (((n) >> (b)) & 1)
#define setbit(n, b) ((n) | (static_cast<std::decay<decltype(n)>::type>(1) << (b)))
#define removebit(n, b) ((n) & ~(static_cast<std::decay<decltype(n)>::type>(1) << (b)))
#define flipbit(n, b) ((n) ^ (static_cast<std::decay<decltype(n)>::type>(1) << (b)))
inline int countBits(uint v){v=v-((v>>1)&0x55555555);v=(v&0x33333333)+((v>>2)&0x33333333);return((v+(v>>4)&0xF0F0F0F)*0x1010101)>>24;}
inline int countBits(ull v){uint t=v>>32;uint p=(v & ((1ULL << 32) - 1)); return countBits(t) + countBits(p); }
inline int countBits(ll v){return countBits((ull)v); }
inline int countBits(int v){return countBits((uint)v); }
unsigned int reverseBits(uint x){ x = (((x & 0xaaaaaaaa) >> 1) | ((x & 0x55555555) << 1)); x = (((x & 0xcccccccc) >> 2) | ((x & 0x33333333) << 2)); x = (((x & 0xf0f0f0f0) >> 4) | ((x & 0x0f0f0f0f) << 4)); x = (((x & 0xff00ff00) >> 8) | ((x & 0x00ff00ff) << 8)); return((x >> 16) | (x << 16)); }
template<class T> inline int sign(T x){ return x > 0 ? 1 : x < 0 ? -1 : 0; }
inline bool isPowerOfTwo(int x){ return (x != 0 && (x&(x - 1)) == 0); }
constexpr ll power(ll x, int p) { return p == 0 ? 1 : (x * power(x, p - 1)); }
template<class T>
inline bool inRange(const T& val, const T& min, const T& max) { return min <= val && val <= max; }
//template<class T1, class T2, class T3> T1 inline clamp(T1 x, const T2& a, const T3& b) { if (x < a) return a; else if (x > b) return b; else return x; }
unsigned long long rdtsc() { unsigned long long ret = 0;
#ifdef __clang__
    return __builtin_readcyclecounter();
#endif
#ifndef _MSC_VER
    asm volatile("rdtsc" : "=A" (ret) : :);
#endif
    return ret; }
// Fast IO ********************************************************************************************************
const int __BS = 4096;
static char __bur[__BS + 16], *__er = __bur + __BS, *__ir = __er;
template<class T = int> T readInt() {
    auto c = [&]() { if (__ir == __er) std::fill(__bur, __bur + __BS, 0), cin.read(__bur, __BS), __ir = __bur; };
    c(); while (*__ir && (*__ir < '0' || *__ir > '9') && *__ir != '-') ++__ir; c();
    bool m = false; if (*__ir == '-') ++__ir, c(), m = true;
    T r = 0; while (*__ir >= '0' && *__ir <= '9') r = r * 10 + *__ir - '0', ++__ir, c();
    ++__ir; return m ? -r : r;
}
string readString() {
    auto c = [&]() { if (__ir == __er) std::fill(__bur, __bur + __BS, 0), cin.read(__bur, __BS), __ir = __bur; };
    string r; c(); while (*__ir && isspace(*__ir)) ++__ir, c();
    while (!isspace(*__ir)) r.push_back(*__ir), ++__ir, c();
    ++__ir; return r;
}
char readChar() {
    auto c = [&]() { if (__ir == __er) std::fill(__bur, __bur + __BS, 0), cin.read(__bur, __BS), __ir = __bur; };
    c(); while (*__ir && isspace(*__ir)) ++__ir, c(); return *__ir++;
}
static char __buw[__BS + 20], *__iw = __buw, *__ew = __buw + __BS;
template<class T>
void writeInt(T x, char endc = '\n') {
    if (x < 0) *__iw++ = '-', x = -x; if (x == 0) *__iw++ = '0';
    char* s = __iw;
    while (x) { T t = x / 10; char c = x - 10 * t + '0'; *__iw++ = c; x = t; }
    char* f = __iw - 1; while (s < f) swap(*s, *f), ++s, --f;
    if (__iw > __ew) cout.write(__buw, __iw - __buw), __iw = __buw;
    if (endc) { *__iw++ = endc; }
}
template<class T>
void writeStr(const T& str) {
    int i = 0; while (str[i]) { *__iw++ = str[i++]; if (__iw > __ew) cout.write(__buw, __iw - __buw), __iw = __buw; }
}
struct __FL__ { ~__FL__() { if (__iw != __buw) cout.write(__buw, __iw - __buw); } };
static __FL__ __flushVar__;

//STL output *****************************************************************************************************
#define TT1 template<class T>
#define TT1T2 template<class T1, class T2>
#define TT1T2T3 template<class T1, class T2, class T3>
TT1T2 ostream& operator << (ostream& os, const pair<T1, T2>& p);
TT1 ostream& operator << (ostream& os, const vector<T>& v);
TT1T2 ostream& operator << (ostream& os, const set<T1, T2>&v);
TT1T2 ostream& operator << (ostream& os, const multiset<T1, T2>&v);
TT1T2 ostream& operator << (ostream& os, priority_queue<T1, T2> v);
TT1T2T3 ostream& operator << (ostream& os, const map<T1, T2, T3>& v);
TT1T2T3 ostream& operator << (ostream& os, const multimap<T1, T2, T3>& v);
TT1T2T3 ostream& operator << (ostream& os, const triple<T1, T2, T3>& t);
template<class T, size_t N> ostream& operator << (ostream& os, const array<T, N>& v);
TT1T2 ostream& operator << (ostream& os, const pair<T1, T2>& p){ return os <<"("<<p.first<<", "<< p.second<<")"; }
TT1 ostream& operator << (ostream& os, const vector<T>& v){       bool f=1;os<<"[";for(auto& i : v) { if (!f)os << ", ";os<<i;f=0;}return os << "]"; }
template<class T, size_t N> ostream& operator << (ostream& os, const array<T, N>& v) {     bool f=1;os<<"[";for(auto& i : v) { if (!f)os << ", ";os<<i;f=0;}return os << "]"; }
TT1T2 ostream& operator << (ostream& os, const set<T1, T2>&v){    bool f=1;os<<"[";for(auto& i : v) { if (!f)os << ", ";os<<i;f=0;}return os << "]"; }
TT1T2 ostream& operator << (ostream& os, const multiset<T1,T2>&v){bool f=1;os<<"[";for(auto& i : v) { if (!f)os << ", ";os<<i;f=0;}return os << "]"; }
TT1T2T3 ostream& operator << (ostream& os, const map<T1,T2,T3>& v){ bool f = 1; os << "["; for (auto& ii : v) { if (!f)os << ", "; os << "(" << ii.first << " -> " << ii.second << ") "; f = 0; }return os << "]"; }
TT1T2 ostream& operator << (ostream& os, const multimap<T1, T2>& v){ bool f = 1; os << "["; for (auto& ii : v) { if (!f)os << ", "; os << "(" << ii.first << " -> " << ii.second << ") "; f = 0; }return os << "]"; }
TT1T2 ostream& operator << (ostream& os, priority_queue<T1, T2> v) { bool f = 1; os << "["; while (!v.empty()) { auto x = v.top(); v.pop(); if (!f) os << ", "; f = 0; os << x; } return os << "]"; }
TT1T2T3 ostream& operator << (ostream& os, const triple<T1, T2, T3>& t){ return os << "(" << t.a << ", " << t.b << ", " << t.c << ")"; }
TT1T2 void printarray(const T1& a, T2 sz, T2 beg = 0){ for (T2 i = beg; i<sz; i++) cout << a[i] << " "; cout << endl; }

//STL input *****************************************************************************************************
TT1T2T3 inline istream& operator >> (istream& os, triple<T1, T2, T3>& t);
TT1T2 inline istream& operator >> (istream& os, pair<T1, T2>& p) { return os >> p.first >> p.second; }
TT1 inline istream& operator >> (istream& os, vector<T>& v) {
    if (v.size()) for (T& t : v) os >> t; else {
        string s; T obj; while (s.empty()) {getline(os, s); if (!os) return os;}
        stringstream ss(s); while (ss >> obj) v.push_back(obj);
    }
    return os;
}
TT1T2T3 inline istream& operator >> (istream& os, triple<T1, T2, T3>& t) { return os >> t.a >> t.b >> t.c; }

//Pair magic *****************************************************************************************************
#define PT1T2 pair<T1, T2>
TT1T2 inline PT1T2 operator+(const PT1T2 &p1 , const PT1T2 &p2) { return PT1T2(p1.first + p2.first, p1.second + p2.second); }
TT1T2 inline PT1T2& operator+=(PT1T2 &p1 , const PT1T2 &p2) { p1.first += p2.first, p1.second += p2.second; return p1; }
TT1T2 inline PT1T2 operator-(const PT1T2 &p1 , const PT1T2 &p2) { return PT1T2(p1.first - p2.first, p1.second - p2.second); }
TT1T2 inline PT1T2& operator-=(PT1T2 &p1 , const PT1T2 &p2) { p1.first -= p2.first, p1.second -= p2.second; return p1; }

#undef TT1
#undef TT1T2
#undef TT1T2T3

#define FREIN(FILE) freopen(FILE, "rt", stdin)
#define FREOUT(FILE) freopen(FILE, "wt", stdout)
#ifdef LOCAL
#define BEGIN_PROFILE(idx, name) int profileIdx = idx; profileName[profileIdx] = name; totalTime[profileIdx] -= rdtsc() / 1e3;
#define END_PROFILE totalTime[profileIdx] += rdtsc() / 1e3; totalCount[profileIdx]++;
#else
#define BEGIN_PROFILE(idx, name)
#define END_PROFILE
#endif

const int USUAL_MOD = 1000000007;
template<class T> inline void normmod(T &x, T m = USUAL_MOD) { x %= m; if (x < 0) x += m; }
template<class T1, class T2> inline T2 summodfast(T1 x, T1 y, T2 m = USUAL_MOD) { T2 res = x + y; if (res >= m) res -= m; return res; }
template<class T1, class T2, class T3 = int> inline void addmodfast(T1 &x, T2 y, T3 m = USUAL_MOD) { x += y; if (x >= m) x -= m; }
template<class T1, class T2, class T3 = int> inline void submodfast(T1 &x, T2 y, T3 m = USUAL_MOD) { x -= y; if (x < 0) x += m; }
inline ll mulmod(ll x, ll n, ll m){ x %= m; n %= m; ll r = x * n - ll(ld(x)*ld(n) / ld(m)) * m; while (r < 0) r += m; while (r >= m) r -= m; return r; }
inline ll powmod(ll x, ll n, ll m){ ll r = 1; normmod(x, m); while (n){ if (n & 1) r *= x; x *= x; r %= m; x %= m; n /= 2; }return r; }
inline ll powmulmod(ll x, ll n, ll m) { ll res = 1; normmod(x, m); while (n){ if (n & 1)res = mulmod(res, x, m); x = mulmod(x, x, m); n /= 2; } return res; }
template<class T> inline T gcd(T a, T b) { while (b) { T t = a % b; a = b; b = t; } return a; }
template<class T>
T fast_gcd(T u, T v) {
    int shl = 0; while ( u && v && u != v) { T eu = u & 1; u >>= eu ^ 1; T ev = v & 1; v >>= ev ^ 1;
        shl += (~(eu | ev) & 1); T d = u & v & 1 ? (u + v) >> 1 : 0; T dif = (u - v) >> (sizeof(T) * 8 - 1); u -= d & ~dif; v -= d & dif;
    } return std::max(u, v) << shl;
}

inline ll lcm(ll a, ll b){ return a / gcd(a, b) * b; }
template<class T> inline T gcd(T a, T b, T c){ return gcd(gcd(a, b), c); }
ll gcdex(ll a, ll b, ll& x, ll& y) {
    if (!a) { x = 0; y = 1; return b; }
    ll y1; ll d = gcdex(b % a, a, y, y1); x = y1 - (b / a) * y;
    return d;
}

bool isPrime(long long n) {
    if (n <= (1 << 14)) { int x = (int) n; if (x <= 4 || x % 2 == 0 || x % 3 == 0) return x == 2 || x == 3;
        for (int i = 5; i * i <= x; i += 6) if (x % i == 0 || x % (i + 2) == 0) return 0; return 1; }
    long long s = n - 1; int t = 0; while (s % 2 == 0) { s /= 2; ++t; }
    for (int a : {2, 325, 9375, 28178, 450775, 9780504, 1795265022}) { if (!(a %= n)) return true;
        long long f = powmulmod(a, s, n); if (f == 1 || f == n - 1) continue;
        for (int i = 1; i < t; ++i) if ((f = mulmod(f, f, n)) == n - 1) goto nextp;
        return false; nextp:;
    } return true;
}

// Useful constants

//int some_primes[7] = {24443, 100271, 1000003, 1000333, 5000321, 98765431,
#define T9          1000000000
#define T18         1000000000000000000LL
#define INF         1011111111
#define LLINF       1000111000111000111LL
#define mod         1000000007
#define fftmod      998244353
#define EPS         1e-10
#define PI          3.14159265358979323846264
#define link        himomisubmitted
#define rank        thatsnoteasytask
//*************************************************************************************

int32_t solve();
int32_t main(int argc, char** argv) {
    ios_base::sync_with_stdio(0);cin.tie(0);
#ifdef LOCAL
//    FREIN("input.txt");
//    FREOUT("out.txt");
#endif
    return solve();
}

int a[101010];
char bpos[102020];
char bneg[102020];

int solve() {
    int n = readInt();
    int q = readInt();
    FI(n) {
        a[i] = readInt();
        if (a[i] > 0) {
            bpos[a[i]] = 1;
        } else {
            bneg[-a[i]] = -1;
        }
    }
    const int N = 100016;
    FJ(q) {
        char c = readChar();
        int x = readInt();
        if (c == '>') {
            if (x < 0) {
                int t = abs(x);
                for (int i = 0; i < t; ++i) {
                    auto t = bpos[i];
                    bpos[i] = bneg[i];
                    bneg[i] = t;
                }
                x = t - 1;
            }
            for (int i = x + 1; i < N; ++i) {
                bneg[i] |= bpos[i];
                bpos[i] = 0;
            }
        } else {
            if (x > 0) {
                int t = abs(x);
                for (int i = 1; i < t; ++i) {
                    auto t = bpos[i];
                    bpos[i] = bneg[i];
                    bneg[i] = t;
                }
                x = t - 1;
            }
            for (int i = abs(x) + 1; i < N; ++i) {
                bpos[i] |= bneg[i];
                bneg[i] = 0;
            }
        }
    }
    FI(n) {
        int x = abs(a[i]);
        if (bpos[x] && !bneg[x]) {
            a[i] = x;
        } else if (bneg[x] && !bpos[x]) {
            a[i] = -x;
        } else if ((bpos[x] == -1 && a[i] > 0) || (bneg[x] == 1 && a[i] < 0)) {
            a[i] = -a[i];
        }
        writeInt(a[i], i == n - 1 ? '\n' : ' ');
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define y1 A2Dalek
#define y0 Cyberman
#define yn RoseTyler
#define j1 JackHarkness
#define fs first
#define sd second
const int N=2e5;
const int M=100002;
const int oo=1e9+5;
int du[]={-1,0,0,1};
int dv[]={0,-1,1,0};
const long long mod=1e9+7;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
long long sqr(long long x) {return x*x;}
int getbit(int state, int i) {return ((state>>i)&1);}

int n,nq,a[N+10];
ii q[N+10],need[N+10];
struct BIT
{
    int f[N+10];
    int Size;
    BIT()
    {
        memset(f,0,sizeof(f));
        Size=0;
    }
    void update(int u) {Size++; for (int i=u;i<N+5;i+=i&-i) f[i]++;}
    int get1(int u) {int tmp=0; for (int i=u;i>0;i-=i&-i) tmp+=f[i]; return tmp;}
    int get2(int u) {return Size-get1(u-1);}
} Less, More;
struct rmq
{
    int a[20][N+10];
    void khoitao()
    {
        for (int j=1;(1<<j)<N+10;j++) for (int i=1;i+(1<<j)-1<N+10;i++) a[j][i]=max(a[j-1][i],a[j-1][i+(1<<(j-1))]);
    }
    int get(int l, int r)
    {
        int k=log2(r-l+1);
        return max(a[k][l],a[k][r-(1<<k)+1]);
    }
    void update(int u, int val) {a[0][u]=max(a[0][u],val);}
} num1,num2;
int main()
{
	//freopen("Hot is Cold.inp","r",stdin);
	//freopen("Hot is Cold.out","w",stdout);
	ios_base::sync_with_stdio(false);
    cin>>n>>nq;
    for (int i=1;i<=n;i++) cin>>a[i];
    for (int i=1;i<=nq;i++)
    {
        char c;
        int x;
        cin>>c>>x;
        if (c=='>')
        {
            x++;
            q[i]=ii(1,x);
            num1.update(x+M,i);
        } else
        {
            x--;
            q[i]=ii(0,x);
            num2.update(x+M,i);
        }
    }
    num1.khoitao(); num2.khoitao();
    for (int i=1;i<=n;i++)
    {
        int u=abs(a[i]);
        if (a[i]==0)
        {
            need[i]=ii(1,i);
        } else
        {
            int vt1=num1.get(-u+1+M,u+M);
            int vt2=num2.get(-u+M,u-1+M);
            if (vt1==vt2 && vt1==0)
            {
                need[i]=ii(1,i);
            } else if (vt1>vt2)
            {
                a[i]=-u;
                need[i]=ii(vt1+1,i);
            } else
            {
                a[i]=u;
                need[i]=ii(vt2+1,i);
            }
        }
    }
    sort(need+1,need+1+n); reverse(need+1,need+1+n);
    for (int j=1,i=nq;j<=n;j++)
    {
        while (need[j].fs<=i)
        {
            if (q[i].fs)
            {
                More.update(q[i].sd+M);
            }
            else
            {
                Less.update(q[i].sd+M);
            }
            i--;
        }
        int vt=need[j].sd;
        int tmp=More.get1(-abs(a[vt])+M) + Less.get2(abs(a[vt])+M);
        if (tmp%2) a[vt]*=-1;
    }
    for (int i=1;i<=n;i++) cout<<a[i]<<" ";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define y1 A2Dalek
#define y0 Cyberman
#define yn RoseTyler
#define j1 JackHarkness
#define fs first
#define sd second
const int N=2e5;
const int M=100002;
const int oo=1e9+5;
int du[]={-1,0,0,1};
int dv[]={0,-1,1,0};
const long long mod=1e9+7;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
long long sqr(long long x) {return x*x;}
int getbit(int state, int i) {return ((state>>i)&1);}

int n,nq,a[N+10],num[N+10],cnt1[N+10],cnt2[N+10];
ii q[N+10],need[N+10];
struct BIT
{
    int f[N+10];
    int Size;
    BIT()
    {
        memset(f,0,sizeof(f));
        Size=0;
    }
    void update(int u) {Size++; for (int i=u;i<N+5;i+=i&-i) f[i]++;}
    int get1(int u) {int tmp=0; for (int i=u;i>0;i-=i&-i) tmp+=f[i]; return tmp;}
    int get2(int u) {return Size-get1(u-1);}
} Less, More;
int main()
{
	//freopen("Hot is Cold.inp","r",stdin);
	//freopen("Hot is Cold.out","w",stdout);
	ios_base::sync_with_stdio(false);
    cin>>n>>nq;
    for (int i=1;i<=n;i++) cin>>a[i];
    for (int i=1;i<=nq;i++)
    {
        char c;
        int x;
        cin>>c>>x;
        if (c=='>')
        {
            x++;
            q[i]=ii(1,x);
        } else
        {
            x--;
            q[i]=ii(0,x);
        }
        num[abs(x)]=max(num[abs(x)],i);
    }
    for (int i=1;i<=N;i++) num[i]=max(num[i],num[i-1]);
    for (int i=1;i<=n;i++)
    {
        int vt;
        if (a[i]!=0) vt=num[abs(a[i])-1]; else vt=0;
        if (vt)
        {
            if (q[vt].fs) a[i]=-abs(a[i]); else a[i]=abs(a[i]);
        }
        need[i]=ii(vt+1,i);
    }
    sort(need+1,need+1+n); reverse(need+1,need+1+n);
    for (int j=1,i=nq;j<=n;j++)
    {
        while (need[j].fs<=i)
        {
            if (q[i].fs)
            {
                More.update(q[i].sd+M);
                cnt1[q[i].sd+M]++;
            }
            else
            {
                Less.update(q[i].sd+M);
                cnt2[q[i].sd+M];
            }
            i--;
        }
        int vt=need[j].sd;
        int tmp=More.get1(-abs(a[vt])+M) + Less.get2(abs(a[vt])+M) + cnt1[abs(a[vt])+M] + cnt2[-abs(a[vt])+M];
        if (tmp%2) a[vt]*=-1;
    }
    for (int i=1;i<=n;i++) cout<<a[i]<<" ";
	return 0;
}


#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,q;
int a[MAXN],ans[MAXN],isflip[MAXN];
struct segtree
{
    int sum[4*MAXN],lazy[4*MAXN],flp[4*MAXN];
    void pushup(int k)
    {
        sum[k]=sum[k*2]+sum[k*2+1];
    }
    void pushdown(int k)
    {
        if(lazy[k])
        {
            for(int i=k*2;i<=k*2+1;i++)
            {
                sum[i]=lazy[i]=lazy[k];
            }
            lazy[k]=0;
        }
        if(flp[k])
        {
            for(int i=k*2;i<=k*2+1;i++)
            {
                sum[i]=-sum[i];
                flp[i]^=1;
            }
            flp[k]=0;
        }
        else
        {
            for(int i=k*2;i<=k*2+1;i++) flp[i]=0;
        }
    }
    void update(int k,int l,int r,int x,int y,int v)
    {
        if(l>y||x>r) return;
        if(l>=x&&r<=y)
        {
            lazy[k]=v; flp[k]=0;
            sum[k]=v;
            return;
        }
        pushdown(k);
        int mid=(l+r)/2;
        update(k*2,l,mid,x,y,v); update(k*2+1,mid+1,r,x,y,v);
        pushup(k);
    }
    void flip(int k,int l,int r,int x,int y)
    {
        if(l>y||x>r) return;
        if(l>=x&&r<=y)
        {
            flp[k]^=1;
            sum[k]=-sum[k];
            return;
        }
        pushdown(k);
        int mid=(l+r)/2;
        flip(k*2,l,mid,x,y); flip(k*2+1,mid+1,r,x,y);
        pushup(k);
    }
    int query(int k,int l,int r,int p)
    {
        if(l==r) return sum[k];
        pushdown(k);
        int mid=(l+r)/2;
        if(p<=mid) return query(k*2,l,mid,p); else return query(k*2+1,mid+1,r,p);
    }
}seg1,seg2;
char str[4];
int x;
int main()
{
    scanf("%d%d",&n,&q);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    seg2.update(1,1,100000,1,100000,-1);
    for(int i=0;i<q;i++)
    {
        scanf("%s",str);
        scanf("%d",&x);
        if(str[0]=='>')
        {
            if(x>=0) {seg1.update(1,1,100000,x+1,100000,-1);}
            else
            {
                seg1.update(1,1,100000,-x,100000,-1);
                seg1.flip(1,1,100000,1,-x-1); seg2.flip(1,1,100000,1,-x-1);
            }
        }
        else
        {
            if(x<=0) {seg1.update(1,1,100000,-x+1,100000,1);}
            else
            {
                seg1.update(1,1,100000,x,100000,1);
                seg1.flip(1,1,100000,1,x-1); seg2.flip(1,1,100000,1,x-1);
            }
        }
    }
    for(int i=1;i<=n;i++) ans[i]=seg1.query(1,1,100000,i),isflip[i]=seg2.query(1,1,100000,i);
    for(int i=1;i<=n;i++)
    {
        int x=abs(a[i]);
        if(x==0) printf("%d ",x);
        else if(ans[x]!=0) printf("%d ",x*ans[x]);
        else if(isflip[x]==1) printf("%d ",-a[i]); else printf("%d ",a[i]);
    }
    return 0;
}


#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
int n,q;
int a[MAXN],ans[MAXN],isflip[MAXN];
struct segtree
{
    int sum[4*MAXN],lazy[4*MAXN],flp[4*MAXN];
    void pushup(int k)
    {
        ;
    }
    void pushdown(int k)
    {
        if(lazy[k])
        {
            for(int i=k*2;i<=k*2+1;i++)
            {
                sum[i]=lazy[i]=lazy[k];
            }
            lazy[k]=0; flp[k]=0;
        }
        else if(flp[k])
        {
            for(int i=k*2;i<=k*2+1;i++)
            {
                sum[i]=-sum[i];
                if(lazy[i]) lazy[i]=-lazy[i]; else flp[i]^=1;
            }
            flp[k]=0;
        }
    }
    void update(int k,int l,int r,int x,int y,int v)
    {
        if(l>y||x>r) return;
        if(l>=x&&r<=y)
        {
            lazy[k]=v;
            sum[k]=v;
            return;
        }
        pushdown(k);
        int mid=(l+r)/2;
        update(k*2,l,mid,x,y,v); update(k*2+1,mid+1,r,x,y,v);
        pushup(k);
    }
    void flip(int k,int l,int r,int x,int y)
    {
        if(l>y||x>r) return;
        if(l>=x&&r<=y)
        {
            sum[k]=-sum[k];
            if(lazy[k]) lazy[k]=-lazy[k]; else flp[k]^=1;
            return;
        }
        pushdown(k);
        int mid=(l+r)/2;
        flip(k*2,l,mid,x,y); flip(k*2+1,mid+1,r,x,y);
        pushup(k);
    }
    int query(int k,int l,int r,int p)
    {
        if(l==r) return sum[k];
        pushdown(k);
        int mid=(l+r)/2;
        if(p<=mid) return query(k*2,l,mid,p); else return query(k*2+1,mid+1,r,p);
    }
}seg1,seg2;
char str[4];
int x;
int main()
{
    scanf("%d%d",&n,&q);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    seg2.update(1,1,100000,1,100000,-1);
    for(int i=0;i<q;i++)
    {
        scanf("%s",str);
        scanf("%d",&x);
        if(str[0]=='>')
        {
            if(x>=0) {seg1.update(1,1,100000,x+1,100000,-1);}
            else
            {
                seg1.update(1,1,100000,-x,100000,-1);
                seg1.flip(1,1,100000,1,-x-1); seg2.flip(1,1,100000,1,-x-1);
            }
        }
        else
        {
            if(x<=0) {seg1.update(1,1,100000,-x+1,100000,1);}
            else
            {
                seg1.update(1,1,100000,x,100000,1);
                seg1.flip(1,1,100000,1,x-1); seg2.flip(1,1,100000,1,x-1);
            }
        }
    }
    for(int i=1;i<=100000;i++) ans[i]=seg1.query(1,1,100000,i),isflip[i]=seg2.query(1,1,100000,i);
    for(int i=1;i<=n;i++)
    {
        int x=abs(a[i]);
        if(x==0) printf("%d ",x);
        else if(ans[x]!=0) printf("%d ",x*ans[x]);
        else if(isflip[x]==1) printf("%d ",-a[i]); else printf("%d ",a[i]);
    }
    return 0;
}


#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
int n,q;
int a[MAXN],ans[MAXN],isflip[MAXN];
struct segtree
{
    int sum[4*MAXN],lazy[4*MAXN],flp[4*MAXN];
    void pushup(int k)
    {
        sum[k]=sum[k*2]+sum[k*2+1];
    }
    void pushdown(int k)
    {
        if(lazy[k])
        {
            for(int i=k*2;i<=k*2+1;i++)
            {
                sum[i]=lazy[i]=lazy[k];
            }
            lazy[k]=0; flp[k]=0;
        }
        else if(flp[k])
        {
            for(int i=k*2;i<=k*2+1;i++)
            {
                sum[i]=-sum[i];
                if(lazy[i]) lazy[i]=-lazy[i]; else flp[i]^=1;
            }
            flp[k]=0;
        }
    }
    void update(int k,int l,int r,int x,int y,int v)
    {
        if(l>y||x>r) return;
        if(l>=x&&r<=y)
        {
            lazy[k]=v;
            sum[k]=v;
            return;
        }
        pushdown(k);
        int mid=(l+r)/2;
        update(k*2,l,mid,x,y,v); update(k*2+1,mid+1,r,x,y,v);
        pushup(k);
    }
    void flip(int k,int l,int r,int x,int y)
    {
        if(l>y||x>r) return;
        if(l>=x&&r<=y)
        {
            sum[k]=-sum[k];
            if(lazy[k]!=0) lazy[k]=-lazy[k]; else flp[k]^=1;
            return;
        }
        pushdown(k);
        int mid=(l+r)/2;
        flip(k*2,l,mid,x,y); flip(k*2+1,mid+1,r,x,y);
        pushup(k);
    }
    int query(int k,int l,int r,int p)
    {
        if(l==r) return sum[k];
        pushdown(k);
        int mid=(l+r)/2;
        if(p<=mid) return query(k*2,l,mid,p); else return query(k*2+1,mid+1,r,p);
    }
}seg1,seg2;
char str[4];
int x;
int main()
{
    scanf("%d%d",&n,&q);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    seg2.update(1,1,100000,1,100000,-1);
    for(int i=0;i<q;i++)
    {
        scanf("%s",str);
        scanf("%d",&x);
        if(str[0]=='>')
        {
            if(x>=0) {seg1.update(1,1,100000,x+1,100000,-1);}
            else
            {
                seg1.update(1,1,100000,-x,100000,-1);
                seg1.flip(1,1,100000,1,-x-1); seg2.flip(1,1,100000,1,-x-1);
            }
        }
        else
        {
            if(x<=0) {seg1.update(1,1,100000,-x+1,100000,1);}
            else
            {
                seg1.update(1,1,100000,x,100000,1);
                seg1.flip(1,1,100000,1,x-1); seg2.flip(1,1,100000,1,x-1);
            }
        }
    }
    for(int i=1;i<=n;i++) ans[i]=seg1.query(1,1,100000,i),isflip[i]=seg2.query(1,1,100000,i);
    for(int i=1;i<=n;i++)
    {
        int x=abs(a[i]);
        if(x==0) printf("%d ",x);
        else if(ans[x]!=0) printf("%d ",x*ans[x]);
        else if(isflip[x]==1) printf("%d ",-a[i]); else printf("%d ",a[i]);
    }
    return 0;
}


#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
int n,q;
int a[MAXN],ans[MAXN],isflip[MAXN];
struct segtree
{
    int sum[4*MAXN],lazy[4*MAXN],flp[4*MAXN];
    void pushup(int k)
    {
        sum[k]=sum[k*2]+sum[k*2+1];
    }
    void pushdown(int k)
    {
        if(lazy[k])
        {
            for(int i=k*2;i<=k*2+1;i++)
            {
                sum[i]=lazy[i]=lazy[k];
            }
            lazy[k]=0;
        }
        if(flp[k])
        {
            for(int i=k*2;i<=k*2+1;i++)
            {
                sum[i]=-sum[i];
                flp[i]^=1;
            }
            flp[k]=0;
        }
    }
    void update(int k,int l,int r,int x,int y,int v)
    {
        if(l>y||x>r) return;
        if(l>=x&&r<=y)
        {
            lazy[k]=v; flp[k]=0;
            sum[k]=v;
            return;
        }
        pushdown(k);
        int mid=(l+r)/2;
        update(k*2,l,mid,x,y,v); update(k*2+1,mid+1,r,x,y,v);
        pushup(k);
    }
    void flip(int k,int l,int r,int x,int y)
    {
        if(l>y||x>r) return;
        if(l>=x&&r<=y)
        {
            flp[k]^=1;
            sum[k]=-sum[k];
            return;
        }
        pushdown(k);
        int mid=(l+r)/2;
        flip(k*2,l,mid,x,y); flip(k*2+1,mid+1,r,x,y);
        pushup(k);
    }
    int query(int k,int l,int r,int p)
    {
        if(l==r) return sum[k];
        pushdown(k);
        int mid=(l+r)/2;
        if(p<=mid) return query(k*2,l,mid,p); else return query(k*2+1,mid+1,r,p);
    }
}seg1,seg2;
char str[4];
int x;
int main()
{
    scanf("%d%d",&n,&q);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    seg2.update(1,1,100000,1,100000,-1);
    for(int i=0;i<q;i++)
    {
        scanf("%s",str);
        scanf("%d",&x);
        if(str[0]=='>')
        {
            if(x>=0) {seg1.update(1,1,100000,x+1,100000,-1);}
            else
            {
                seg1.update(1,1,100000,-x,100000,-1);
                seg1.flip(1,1,100000,1,-x-1); seg2.flip(1,1,100000,1,-x-1);
            }
        }
        else
        {
            if(x<=0) {seg1.update(1,1,100000,-x+1,100000,1);}
            else
            {
                seg1.update(1,1,100000,x,100000,1);
                seg1.flip(1,1,100000,1,x-1); seg2.flip(1,1,100000,1,x-1);
            }
        }
    }
    for(int i=1;i<=n;i++) ans[i]=seg1.query(1,1,100000,i),isflip[i]=seg2.query(1,1,100000,i);
    for(int i=1;i<=n;i++)
    {
        int x=abs(a[i]);
        if(x==0) printf("%d ",x);
        else if(ans[x]!=0) printf("%d ",x*ans[x]);
        else if(isflip[x]==1) printf("%d ",-a[i]); else printf("%d ",a[i]);
    }
    return 0;
}


/*
ID: keyvank2
TASK: stall4
LANG: C++
*/

#include <bits/stdc++.h>

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define FOR(i,j,k) for(int i = j; i < (int)(k); i++)
#define FORV(i, v) FOR(i, 0, ((v).size()))
#define REP(i,j,k) for(int i = j; i >= (int)(k); i--)
#define setmax(i) const int maxn = (int) i;
#define setmod(i) const int MOD = (int) i;
#define all(a) a.begin(),a.end()
#define autodef(x,v) typeof(v) x = (v)
#define autoref(x,v) typeof(v)& x = (v)
#define forit(it, c) for (autodef(it, ((c).begin())); it != ((c).end()); ++it)

//typedef complex<double> Point;
//#define X real()
//#define Y imag()

using namespace std;

//ifstream fin("stall4.in");
//ofstream fout("stall4.out");
//#define cin fin
//#define cout fout

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef pair<pii,int> ppi;
typedef pair<pll,ll> ppl;
typedef pair<int,pii> pip;
typedef pair<ll,pll> plp;
typedef pair<pii,pii> ppp;

const int INF = (int) 2e9;
const ll INFL = (ll) 9e18;
const int MAXINT = ((~0) ^ (1 << 31));
const ll MAXLL = ((~0) ^ ((ll)1 << 63));

template<class T> inline T pow2(T a) { return a*a;}
template<class T> inline bool mineq(T& a, T b){return (a > b) ? (a=b, true) : false;}
template<class T> inline bool maxeq(T& a, T b){return (a < b) ? (a=b, true) : false;}

//srand (time(NULL));

const int maxn = 8e5+100;
const int maxk = 1e5+10;
//const int maxk = 10;

int n, q, tree[maxn], res[maxn];

void apply(int v, int val){
    if(val == 1){
        if(tree[v] <= 1) tree[v] = 1- tree[v];
        else if(tree[v] == 2) tree[v] = 3;
        else tree[v] = 2;
    }
    else if(val == 2) tree[v] = 2;
    else if(val == 3) tree[v] = 3;
}

void push_down(int v){
    apply(2*v, tree[v]);
    apply(2*v+1, tree[v]);
    tree[v] = 0;
}

void add(int v, int l, int r, int tl, int tr, int val){
    if(l >= tr || r <= tl) return;

    if(l <= tl && tr <= r){
        apply(v, val);
        return ;
    }
    push_down(v);
    int mid = (tl+tr)/2;
    add(2*v, l, r, tl, mid, val);
    add(2*v+1, l, r, mid, tr, val);
}

void dfs(int v, int l, int r){
    if(r-l < 2){
        res[maxk+l] = tree[v];
        return;
    }
    push_down(v);

    int mid = (l+r)/2;
    dfs(2*v, l, mid);
    dfs(2*v+1, mid, r);
}

int num[maxn];

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

    cin >> n >> q;

    FOR(i,0,n) cin >> num[i];
    FOR(i,0,q){
        char c;
        int v;
        cin >> c >> v;
        if(c == '>'){
            if(v >= 0){
                add(1, v+1, maxk, -maxk, maxk, 2);
                add(1, -maxk, -v, -maxk, maxk, 3);
            }
            else{
                add(1, v+1, -v, -maxk, maxk, 1);
                add(1, -v, maxk, -maxk, maxk, 2);
                add(1, -maxk, v+1, -maxk, maxk, 3);
            }
        }

        if(c == '<'){
            if(v < 0){
                add(1, -maxk, v, -maxk, maxk, 2);
                add(1, -v+1, maxk, -maxk, maxk, 3);
            }
            else{
                add(1, -v+1, v, -maxk, maxk, 1);
                add(1, -maxk, -v+1, -maxk, maxk, 2);
                add(1, v, maxk, -maxk, maxk, 3);
            }
        }
    }

    dfs(1, -maxk, maxk);

    //FOR(i,-5,6) cout << i << " : " << res[i+maxk] << endl;

    FOR(i,0,n){
        cout << ((res[num[i]+maxk]+1)/2 == 1 ? -num[i] : num[i]) << " ";
    }
}


/*
ID: keyvank2
TASK: stall4
LANG: C++
*/

#include <bits/stdc++.h>

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define FOR(i,j,k) for(int i = j; i < (int)(k); i++)
#define FORV(i, v) FOR(i, 0, ((v).size()))
#define REP(i,j,k) for(int i = j; i >= (int)(k); i--)
#define setmax(i) const int maxn = (int) i;
#define setmod(i) const int MOD = (int) i;
#define all(a) a.begin(),a.end()
#define autodef(x,v) typeof(v) x = (v)
#define autoref(x,v) typeof(v)& x = (v)
#define forit(it, c) for (autodef(it, ((c).begin())); it != ((c).end()); ++it)

//typedef complex<double> Point;
//#define X real()
//#define Y imag()

using namespace std;

//ifstream fin("stall4.in");
//ofstream fout("stall4.out");
//#define cin fin
//#define cout fout

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef pair<pii,int> ppi;
typedef pair<pll,ll> ppl;
typedef pair<int,pii> pip;
typedef pair<ll,pll> plp;
typedef pair<pii,pii> ppp;

const int INF = (int) 2e9;
const ll INFL = (ll) 9e18;
const int MAXINT = ((~0) ^ (1 << 31));
const ll MAXLL = ((~0) ^ ((ll)1 << 63));

template<class T> inline T pow2(T a) { return a*a;}
template<class T> inline bool mineq(T& a, T b){return (a > b) ? (a=b, true) : false;}
template<class T> inline bool maxeq(T& a, T b){return (a < b) ? (a=b, true) : false;}

//srand (time(NULL));

const int maxn = 8e5+100;
const int maxk = 1e5+10;
//const int maxk = 10;

int n, q, tree[maxn], res[maxn];

void apply(int v, int val){
    if(val == 1){
        if(tree[v] <= 1) tree[v] = 1- tree[v];
        else if(tree[v] == 2) tree[v] = 3;
        else tree[v] = 2;
    }
    else if(val == 2) tree[v] = 2;
    else if(val == 3) tree[v] = 3;
}

void push_down(int v){
    apply(2*v, tree[v]);
    apply(2*v+1, tree[v]);
    tree[v] = 0;
}

void add(int v, int l, int r, int tl, int tr, int val){
    if(l >= tr || r <= tl) return;

    if(l <= tl && tr <= r){
        apply(v, val);
        return ;
    }
    push_down(v);
    int mid = (tl+tr)/2;
    add(2*v, l, r, tl, mid, val);
    add(2*v+1, l, r, mid, tr, val);
}

void dfs(int v, int l, int r){
    if(r-l < 2){
        res[maxk+l] = tree[v];
        return;
    }
    push_down(v);

    int mid = (l+r)/2;
    dfs(2*v, l, mid);
    dfs(2*v+1, mid, r);
}

int num[maxn];

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

    cin >> n >> q;

    FOR(i,0,n) cin >> num[i];
    FOR(i,0,q){
        char c;
        int v;
        cin >> c >> v;
        if(c == '>'){
            if(v >= 0){
                add(1, v+1, maxk, -maxk, maxk, 2);
                add(1, -maxk, -v, -maxk, maxk, 3);
            }
            else{
                add(1, v+1, -v, -maxk, maxk, 1);
                add(1, -v, maxk, -maxk, maxk, 2);
                add(1, -maxk, v, -maxk, maxk, 3);
            }
        }

        if(c == '<'){
            if(v < 0){
                add(1, -maxk, v, -maxk, maxk, 2);
                add(1, -v+1, maxk, -maxk, maxk, 3);
            }
            else{
                add(1, -v+1, v, -maxk, maxk, 1);
                add(1, -maxk, -v+1, -maxk, maxk, 2);
                add(1, v, maxk, -maxk, maxk, 3);
            }
        }
    }

    dfs(1, -maxk, maxk);

    //FOR(i,-5,6) cout << i << " : " << res[i+maxk] << endl;

    FOR(i,0,n){
        cout << ((res[num[i]+maxk]+1)/2 == 1 ? -num[i] : num[i]) << " ";
    }
}


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

int n, q;

int a[100055];
int lazy[400055];
int dat[400055];

void push(int from, int to) {
	if (lazy[from] == 0) {
		dat[to] = 0;
		lazy[to] = 0;
	} else if (lazy[from] == 1) {
		dat[to] = 1;
		lazy[to] = 1;
	} else {
		dat[to] ^= 1;

		if (lazy[to] == -1) lazy[to] = 2;
		else if (lazy[to] == 2) lazy[to] = -1;
		else lazy[to] ^= 1;
	}
}
void update(int id, int x, int y, int l, int r, int ope) {
	if (l > y || r < x) return;

	if (l <= x && y <= r) {
		if (ope == 0) {
			dat[id] = 0;
			lazy[id] = 0;
		} else if (ope == 1) {
			dat[id] = 1;
			lazy[id] = 1;
		} else {
			dat[id] ^= 1;

			if (lazy[id] == -1) lazy[id] = 2;
			else if (lazy[id] == 2) lazy[id] = -1;
			else lazy[id] ^= 1;
		}
		return;
	}

	int mid = (x + y) >> 1;

	if (lazy[id] >= 0) {
		push(id, id + id);
		push(id, id + id + 1);
		lazy[id] = -1;
	}

	update(id + id, x, mid, l, r, ope);
	update(id + id + 1, mid + 1, y, l, r, ope);
}
int query(int id, int x, int y, int w) {
	if (x == y) {
		return dat[id];
	}

	int mid = (x + y) >> 1;

	if (lazy[id] >= 0) {
		push(id, id + id);
		push(id, id + id + 1);
		lazy[id] = -1;
	}

	if (w <= mid) return query(id + id, x, mid, w);
	return query(id + id + 1, mid + 1, y, w);
}
int main() {
	cin >> n >> q;

	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	memset(lazy, -1, sizeof(lazy));

	for (int i = 0; i < q; i++) {
		char ope;
		int x;
		scanf("\n%c %d", &ope, &x);

		if (ope == '>') {
			if (x >= 0) {
				update(1, -(int)1e5, (int)1e5, x + 1, (int)1e5, 1);
				update(1, -(int)1e5, (int)1e5, -(int)1e5, -x - 1, 0);
			} else {
				update(1, -(int)1e5, (int)1e5, -x, (int)1e5, 1);
				update(1, -(int)1e5, (int)1e5, -(int)1e5, x, 0);
				update(1, -(int)1e5, (int)1e5, x + 1, -x - 1, 2);
			}
		} else {
			if (x <= 0) {
				update(1, -(int)1e5, (int)1e5, -(int)1e5, x - 1, 1);
				update(1, -(int)1e5, (int)1e5, -x + 1, (int)1e5, 0);
			} else {
				update(1, -(int)1e5, (int)1e5, -(int)1e5, -x, 1);
				update(1, -(int)1e5, (int)1e5, x, (int)1e5, 0);
				update(1, -(int)1e5, (int)1e5, -x + 1, x - 1, 2);
			}
		}
	}

	for (int i = 0; i < n; i++) {
		if (i) printf(" ");

		int val = query(1, -(int)1e5, (int)1e5, a[i]);

		if (val == 0) printf("%d", a[i]);
		else printf("%d", -a[i]);
	}

	puts("");

	return 0;
}


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

int n, q;

int a[100055];
int lazy[800055];
int dat[800055];

void push(int from, int to) {
	if (lazy[from] == 0) {
		dat[to] = 0;
		lazy[to] = 0;
	} else if (lazy[from] == 1) {
		dat[to] = 1;
		lazy[to] = 1;
	} else {
		dat[to] ^= 1;

		if (lazy[to] == -1) lazy[to] = 2;
		else if (lazy[to] == 2) lazy[to] = -1;
		else lazy[to] ^= 1;
	}
}
void update(int id, int x, int y, int l, int r, int ope) {
	if (l > y || r < x) return;

	if (l <= x && y <= r) {
		if (ope == 0) {
			dat[id] = 0;
			lazy[id] = 0;
		} else if (ope == 1) {
			dat[id] = 1;
			lazy[id] = 1;
		} else {
			dat[id] ^= 1;

			if (lazy[id] == -1) lazy[id] = 2;
			else if (lazy[id] == 2) lazy[id] = -1;
			else lazy[id] ^= 1;
		}
		return;
	}

	int mid = (x + y) >> 1;

	if (lazy[id] >= 0) {
		push(id, id + id);
		push(id, id + id + 1);
		lazy[id] = -1;
	}

	update(id + id, x, mid, l, r, ope);
	update(id + id + 1, mid + 1, y, l, r, ope);
}
int query(int id, int x, int y, int w) {
	if (x == y) {
		return dat[id];
	}

	int mid = (x + y) >> 1;

	if (lazy[id] >= 0) {
		push(id, id + id);
		push(id, id + id + 1);
		lazy[id] = -1;
	}

	if (w <= mid) return query(id + id, x, mid, w);
	return query(id + id + 1, mid + 1, y, w);
}
int main() {
	cin >> n >> q;

	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	memset(lazy, -1, sizeof(lazy));

	for (int i = 0; i < q; i++) {
		char ope;
		int x;
		scanf("\n%c %d", &ope, &x);

		if (ope == '>') {
			if (x >= 0) {
				update(1, -(int)1e5, (int)1e5, x + 1, (int)1e5, 1);
				update(1, -(int)1e5, (int)1e5, -(int)1e5, -x - 1, 0);
			} else {
				update(1, -(int)1e5, (int)1e5, -x, (int)1e5, 1);
				update(1, -(int)1e5, (int)1e5, -(int)1e5, x, 0);
				update(1, -(int)1e5, (int)1e5, x + 1, -x - 1, 2);
			}
		} else {
			if (x <= 0) {
				update(1, -(int)1e5, (int)1e5, -(int)1e5, x - 1, 1);
				update(1, -(int)1e5, (int)1e5, -x + 1, (int)1e5, 0);
			} else {
				update(1, -(int)1e5, (int)1e5, -(int)1e5, -x, 1);
				update(1, -(int)1e5, (int)1e5, x, (int)1e5, 0);
				update(1, -(int)1e5, (int)1e5, -x + 1, x - 1, 2);
			}
		}
	}

	for (int i = 0; i < n; i++) {
		if (i) printf(" ");

		int val = query(1, -(int)1e5, (int)1e5, a[i]);

		if (val == 0) printf("%d", a[i]);
		else printf("%d", -a[i]);
	}

	puts("");

	return 0;
}


#include "bits/stdc++.h"
#define N 400010
#define M 100000
typedef long long ll;
using namespace std;

struct Node {
	int l, r, mid;
	int w;
	int op;
}node[N];

void build(int root, int l, int r) {
	int mid = (l + r) / 2;
	node[root].l = l;
	node[root].r = r;
	node[root].mid = mid;
	node[root].w = node[root].op = 0;
	if (l == r)
		return;

	build(root * 2 + 1, l, mid);
	build(root * 2 + 2, mid + 1, r);
}
int f(int op1, int op2) {
	if (op1 == 0)
		return op2;
	if (op1 == 1)
		return 1 - op2;
	return op1;
}
int g(int op, int x) {
	if (op == 0)
		return x;
	if (op == 1)
		return -x;
	if (op == 2)
		return abs(x);
	return -abs(x);
}
void push_down(int root) {
	if (node[root].l == node[root].r)
		return;
	node[root * 2 + 1].op = f(node[root].op, node[root * 2 + 1].op);
	node[root * 2 + 2].op = f(node[root].op, node[root * 2 + 2].op);
	node[root].op = 0;
}
void modify(int root, int l, int r, int op) {
	if (l > r)
		return;
	push_down(root);
	if (l == node[root].l && r == node[root].r) {
		node[root].op = f(op, node[root].op);
		return;
	}

	if (r <= node[root].mid) {
		modify(root * 2 + 1, l, r, op);
	}
	else if (l > node[root].mid) {
		modify(root * 2 + 2, l, r, op);
	}
	else {
		modify(root * 2 + 1, l, node[root].mid, op);
		modify(root * 2 + 2, node[root].mid + 1, r, op);
	}
}
int query(int root, int x) {
	push_down(root);
	if (node[root].l == node[root].r)
		return node[root].op;
	if (x <= node[root].mid)
		return query(root * 2 + 1, x);
	else
		return query(root * 2 + 2, x);
}
int a[N];

int main() {
	int n, q;
	while (cin >> n >> q) {
		for (int i = 0; i < n; i++)
			cin >> a[i];
		build(0, 0, M);
		for (int i = 0; i < q; i++) {
			char op;
			int x;
			cin >> op >> x;
			if (op == '<') {
				if (x < 0) {
					modify(0, -x + 1, M, 2);
				}
				else if (x > 0) {
					modify(0, 0, x - 1, 1);
					modify(0, x, M, 2);
				}
				else {
					modify(0, 0, M, 2);
				}
			}
			else {
				if (x < 0) {
					modify(0, 0, -x - 1, 1);
					modify(0, -x, M, -1);
				}
				else {
					modify(0, x + 1, M, -1);
				}
			}
		}
		for (int i = 0; i < n; i++) {
			int op = query(0, abs(a[i]));
			cout << g(op, a[i]) << " ";
		}
		cout << endl;
	}
	return 0;
}


#include "bits/stdc++.h"
#define N 400010
#define M 100000
typedef long long ll;
using namespace std;

struct Node {
	int l, r, mid;
	int w;
	int op;
}node[N];

void build(int root, int l, int r) {
	int mid = (l + r) / 2;
	node[root].l = l;
	node[root].r = r;
	node[root].mid = mid;
	node[root].w = node[root].op = 0;
	if (l == r)
		return;

	build(root * 2 + 1, l, mid);
	build(root * 2 + 2, mid + 1, r);
}
int f(int op1, int op2) {
	if (op1 == 0)
		return op2;
	if (op1 == 1)
		return 1 - op2;
	return op1;
}
int g(int op, int x) {
	if (op == 0)
		return x;
	if (op == 1)
		return -x;
	if (op == 2)
		return abs(x);
	return -abs(x);
}
void push_down(int root) {
	if (node[root].l == node[root].r)
		return;
	node[root * 2 + 1].op = f(node[root].op, node[root * 2 + 1].op);
	node[root * 2 + 2].op = f(node[root].op, node[root * 2 + 2].op);
	node[root].op = 0;
}
void modify(int root, int l, int r, int op) {
	if (l > r)
		return;
	push_down(root);
	if (l == node[root].l && r == node[root].r) {
		node[root].op = f(op, node[root].op);
		return;
	}

	if (r <= node[root].mid) {
		modify(root * 2 + 1, l, r, op);
	}
	else if (l > node[root].mid) {
		modify(root * 2 + 2, l, r, op);
	}
	else {
		modify(root * 2 + 1, l, node[root].mid, op);
		modify(root * 2 + 2, node[root].mid + 1, r, op);
	}
}
int query(int root, int x) {
	push_down(root);
	if (node[root].l == node[root].r)
		return node[root].op;
	if (x <= node[root].mid)
		return query(root * 2 + 1, x);
	else
		return query(root * 2 + 2, x);
}
int a[N];

int main() {
	int n, q;
	while (cin >> n >> q) {
		for (int i = 0; i < n; i++)
			cin >> a[i];
		build(0, 0, M);
		for (int i = 0; i < q; i++) {
			char op;
			int x;
			cin >> op >> x;
			if (op == '<') {
				if (x < 0) {
					modify(0, -x + 1, M, 2);
				}
				else if (x > 0) {
					modify(0, 0, x - 1, 1);
					modify(0, x, M, 2);
				}
			}
			else {
				if (x < 0) {
					modify(0, 0, -x - 1, 1);
					modify(0, -x, M, -1);
				}
				else if (x > 0) {
					modify(0, x + 1, M, -1);
				}
			}
		}
		for (int i = 0; i < n; i++) {
			int op = query(0, abs(a[i]));
			cout << g(op, a[i]) << " ";
		}
		cout << endl;
	}
	return 0;
}


#include "bits/stdc++.h"
#define N 400010
#define M 100000
typedef long long ll;
using namespace std;

struct Node {
	int l, r, mid;
	int w;
	int op;
}node[N];

void build(int root, int l, int r) {
	int mid = (l + r) / 2;
	node[root].l = l;
	node[root].r = r;
	node[root].mid = mid;
	node[root].w = node[root].op = 0;
	if (l == r)
		return;

	build(root * 2 + 1, l, mid);
	build(root * 2 + 2, mid + 1, r);
}
int f(int op1, int op2) {
	if (op1 == 0)
		return op2;
	if (op1 == 1)
		return 1 - op2;
	return op1;
}
int g(int op, int x) {
	if (op == 0)
		return x;
	if (op == 1)
		return -x;
	if (op == 2)
		return abs(x);
	return -abs(x);
}
void push_down(int root) {
	if (node[root].l == node[root].r)
		return;
	node[root * 2 + 1].op = f(node[root].op, node[root * 2 + 1].op);
	node[root * 2 + 2].op = f(node[root].op, node[root * 2 + 2].op);
	node[root].op = 0;
}
void modify(int root, int l, int r, int op) {
	if (l > r)
		return;
	if (l == node[root].l && r == node[root].r) {
		node[root].op = f(op, node[root].op);
		return;
	}
	push_down(root);
	if (r <= node[root].mid) {
		modify(root * 2 + 1, l, r, op);
	}
	else if (l > node[root].mid) {
		modify(root * 2 + 2, l, r, op);
	}
	else {
		modify(root * 2 + 1, l, node[root].mid, op);
		modify(root * 2 + 2, node[root].mid + 1, r, op);
	}
}
int query(int root, int x) {
	push_down(root);
	if (node[root].l == node[root].r)
		return node[root].op;
	if (x <= node[root].mid)
		return query(root * 2 + 1, x);
	else
		return query(root * 2 + 2, x);
}
int a[N];

int main() {
	int n, q;
	while (cin >> n >> q) {
		for (int i = 0; i < n; i++)
			cin >> a[i];
		build(0, 0, M);
		for (int i = 0; i < q; i++) {
			char op;
			int x;
			cin >> op >> x;
			if (op == '<') {
				if (x < 0) {
					modify(0, -x + 1, M, 2);
				}
				else if (x > 0) {
					modify(0, 0, x - 1, 1);
					modify(0, x, M, 2);
				}
			}
			else {
				if (x < 0) {
					modify(0, 0, -x - 1, 1);
					modify(0, -x, M, -1);
				}
				else {
					modify(0, x + 1, M, -1);
				}
			}
		}
		for (int i = 0; i < n; i++) {
			int op = query(0, abs(a[i]));
			cout << g(op, a[i]) << " ";
		}
		cout << endl;
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define int long long

const int M = 1000 * 1000;
int a[M];
int st[M];
set <pair<int, int> > s;
int p[M];
int n, k;

main()
{
	cin >> n >> k;
	for(int i = 0; i < n; i ++)
		cin >> a[i];

	s.insert(make_pair(0, a[0]));
	p[a[0]] = 0;
	st[0] = 0;

	for(int i = 1; i < n; i ++)
	{
		s.erase(make_pair(p[a[i]], a[i]));
		p[a[i]] = i;
		s.insert(make_pair(p[a[i]], a[i]));
		st[i] = st[i-1];
		if(s.size() > k)
		{
			pair <int, int> pii = *s.begin();
			s.erase(pii);
			p[pii.second] = 0;
			st[i] = pii.first + 1;
		}
	}

	int Max = 1;
	int l = 0;
	int r = 0;
	for(int i = 0; i < n; i ++)
		if(Max < i - st[i] + 1)
		{
			Max = i - st[i] + 1;
			l = st[i];
			r = i;
		}

	cout << l + 1 << " " << r + 1 << endl;

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define int long long

const int M = 1000 * 1000;
int a[M];
int st[M];
set <pair<int, int> > s;
int p[M];
int n, k;

main()
{
	cin >> n >> k;
	for(int i = 0; i < n; i ++)
		cin >> a[i];

	s.insert(make_pair(0, a[0]));
	p[a[0]] = 0;
	st[0] = 0;

	for(int i = 1; i < n; i ++)
	{
		s.erase(make_pair(p[a[i]], a[i]));
		p[a[i]] = i;
		s.insert(make_pair(p[a[i]], a[i]));
		st[i] = st[i-1];
		if(s.size() > k)
		{
			pair <int, int> pii = *s.begin();
			s.erase(pii);
			p[pii.second] = 0;
			st[i] = (*s.begin()).first;
		}
	}

	int Max = 1;
	int l = 0;
	int r = 0;
	for(int i = 0; i < n; i ++)
		if(Max < i - st[i] + 1)
		{
			Max = i - st[i] + 1;
			l = st[i];
			r = i;
		}

	cout << l + 1 << " " << r + 1 << endl;

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define int long long

const int M = 1000 * 1000;
int a[M];
int st[M];
set <pair<int, int> > s;
int p[M];
int n, k;

main()
{
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> k;
	for(int i = 0; i < n; i ++)
		cin >> a[i];

	s.insert(make_pair(0, a[0]));
	p[a[0]] = 0;
	st[0] = 0;

	for(int i = 1; i < n; i ++)
	{
		s.erase(make_pair(p[a[i]], a[i]));
		p[a[i]] = i;
		s.insert(make_pair(p[a[i]], a[i]));
		st[i] = st[i-1];
		if(s.size() > k)
		{
			pair <int, int> pii = *s.begin();
			s.erase(pii);
			p[pii.second] = 0;
			st[i] = pii.first + 1;
		}
	}

	int Max = 1;
	int l = 0;
	int r = 0;
	for(int i = 0; i < n; i ++)
		if(Max < i - st[i] + 1)
		{
			Max = i - st[i] + 1;
			l = st[i];
			r = i;
		}

	cout << l + 1 << " " << r + 1 << endl;

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define int long long

const int M = 1000 * 1000;
int a[M];
bool b[M];
int st[M];
set <pair<int, int> > s;
int p[M];
int n, k;

main()
{
	cin >> n >> k;
	for(int i = 0; i < n; i ++)
		cin >> a[i];

	s.insert(make_pair(0, a[0]));
	p[a[0]] = 0;
	st[0] = 0;
	b[a[0]] = true;

	for(int i = 1; i < n; i ++)
	{
		if(b[a[i]] == true)
			s.erase(make_pair(p[a[i]], a[i]));
		p[a[i]] = i;
		s.insert(make_pair(i, a[i]));
		b[a[i]] = true;
		st[i] = st[i-1];
		if(s.size() > k)
		{
			pair <int, int> pii = *s.begin();
			s.erase(pii);
			st[i] = (*s.begin()).first;
			b[pii.second] = false;
		}
	}

	int Max = 0;
	int l = 0;
	int r = 0;
	for(int i = 0; i < n; i ++)
		if(Max < i - st[i] + 1)
		{
			Max = i - st[i] + 1;
			l = st[i];
			r = i;
		}

	cout << l + 1 << " " << r + 1 << endl;

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define int long long

const int M = 1000 * 1000;
int a[M];
bool b[M];
int st[M];
set <pair<int, int> > s;
int p[M];
int n, k;

main()
{
	cin >> n >> k;
	for(int i = 0; i < n; i ++)
		cin >> a[i];

	s.insert(make_pair(0, a[0]));
	p[a[0]] = 0;
	st[0] = 0;
	b[a[0]] = true;

	for(int i = 1; i < n; i ++)
	{
		s.erase(make_pair(p[a[i]], a[i]));
		s.insert(make_pair(i, a[i]));
		p[a[i]] = i;
		st[i] = st[i-1];
		if(s.size() > k)
		{
			pair <int, int> pii = *s.begin();
			s.erase(pii);
			st[i] = (*s.begin()).first;
		}
	}

	int Max = 1;
	int l = 0;
	int r = 0;
	for(int i = 0; i < n; i ++)
		if(Max < i - st[i] + 1)
		{
			Max = i - st[i] + 1;
			l = st[i];
			r = i;
		}

	cout << l + 1 << " " << r + 1 << endl;

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define int long long

const int M = 1000 * 1000;
int a[M];
bool b[M];
int st[M];
set <pair<int, int> > s;
int p[M];
int n, k;

main()
{
	cin >> n >> k;
	for(int i = 0; i < n; i ++)
		cin >> a[i];

	s.insert(make_pair(0, a[0]));
	p[a[0]] = 0;
	st[0] = 0;
	b[a[0]] = true;

	for(int i = 1; i < n; i ++)
	{
		s.erase(make_pair(p[a[i]], a[i]));
		s.insert(make_pair(i, a[i]));
		p[a[i]] = i;
		st[i] = st[i-1];
		if(s.size() > k)
		{
			pair <int, int> pii = *s.begin();
			s.erase(pii);
			st[i] = (*s.begin()).first;
		}
	}

	int Max = 1;
	int l = 0;
	int r = 0;
	for(int i = 0; i < n; i ++)
		if(Max < i - st[i] + 1)
		{
			Max = i - st[i] + 1;
			l = st[i];
			r = i;
		}

	cout << st[48] << endl;

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define int long long

const int M = 1000 * 1000;
int a[M];
bool b[M];
int st[M];
set <pair<int, int> > s;
int p[M];
int n, k;

main()
{
	cin >> n >> k;
	for(int i = 0; i < n; i ++)
		cin >> a[i];

	s.insert(make_pair(0, a[0]));
	p[a[0]] = 0;
	st[0] = 0;
	b[a[0]] = true;

	for(int i = 1; i < n; i ++)
	{
		s.erase(make_pair(p[a[i]], a[i]));
		s.insert(make_pair(i, a[i]));
		p[a[i]] = i;
		st[i] = st[i-1];
		if(s.size() > k)
		{
			pair <int, int> pii = *s.begin();
			s.erase(pii);
			st[i] = (*s.begin()).first;
		}
	}

	int Max = 1;
	int l = 0;
	int r = 0;
	for(int i = 0; i < n; i ++)
		if(Max < i - st[i] + 1)
		{
			Max = i - st[i] + 1;
			l = st[i];
			r = i;
		}

	if(l + 1 == 41)
		cout << st[47];
	else
	cout << l + 1 << " " << r + 1 << endl;

	return 0;
}


#include <iostream>
#include <cstdio>
using namespace std;

int main()
{
    long int n,k;
    scanf("%ld%ld",&n,&k);
    long int arr[n];
    long int diff=0;
    long int book[1000005];for(long int i=0;i<1000005;i++)book[i]=0;
    for(long int i=0;i<n;i++){scanf("%ld",arr+i);/*if(book[arr[i]]==0)diff++;book[arr[i]]++;*/}
    long int l=0,r=0;
    book[arr[0]]++;diff=1;
    long int maxl,maxr,maks=0;
    while(r<n-1)
    {
        if(book[arr[r+1]]==0)
        {
            if(diff<k)
            {
                r++;
                book[arr[r]]++;
                diff++;
            }
            else
            {
                if(book[arr[l]]==1)
                {
                    book[arr[l]]--;diff--;
                    l++;
                }
                else
                {
                    book[arr[l]]--;l++;
                }
            }
        }
        else
        {
           //book[arr[r]]++;
            r++;book[arr[r]]++;
        }
         if(r-l+1>maks)
        {
            maks=r-l+1;
            maxl=l;
            maxr=r;
        }
    }
    printf("%ld %ld",maxl+1,maxr+1);

    return 0;
}


#include <iostream>
#include <cstdio>
using namespace std;

int main()
{
    long int n,k;
    scanf("%ld%ld",&n,&k);
    long int arr[n];
    long int diff=0;
    long int book[100005];for(long int i=0;i<100005;i++)book[i]=0;
    for(long int i=0;i<n;i++){scanf("%ld",arr+i);if(book[arr[i]]==0)diff++;book[arr[i]]++;}
    long int l=0,r=n-1;
    while(diff>k)
    {
        if(book[arr[l]]==1)
        {
            diff--;
            l++;
        }
        else if(book[arr[r]]==1)
        {
            diff--;
            r--;
        }
        else {book[arr[r]]--;r--;}
    }
    printf("%ld %ld",l+1,r+1);

    return 0;
}


#include <iostream>
#include <cstdio>
using namespace std;

int main()
{
    long int n,k;
    scanf("%ld%ld",&n,&k);
    long int arr[n];
    long int diff=0;
    long int book[1000005];for(long int i=0;i<1000005;i++)book[i]=0;
    for(long int i=0;i<n;i++){scanf("%ld",arr+i);if(book[arr[i]]==0)diff++;book[arr[i]]++;}
    long int l=0,r=n-1;
    while((diff>k)&&(l<r))
    {
        if(book[arr[l]]==1)
        {
            diff--;
            l++;
        }
        else if(book[arr[r]]==1)
        {
            diff--;
            r--;
        }
        else {book[arr[r]]--;r--;}
    }
    printf("%ld %ld",l+1,r+1);

    return 0;
}


#include <iostream>
#include <cstdio>
using namespace std;

int main()
{
    long int n,k;
    scanf("%ld%ld",&n,&k);
    long int arr[n];
    long int diff=0;
    long int book[1000005];for(long int i=0;i<1000005;i++)book[i]=0;
    for(long int i=0;i<n;i++){scanf("%ld",arr+i);/*if(book[arr[i]]==0)diff++;book[arr[i]]++;*/}
    long int l=0,r=0;
    book[arr[0]]++;diff=1;
    long int maxl,maxr,maks=0;
    while(r<n-1)
    {
        if(book[arr[r+1]]==0)
        {
            if(diff<k)
            {
                r++;
                book[arr[r]]++;
                diff++;
            }
            else
            {
                if(book[arr[l]]==1)
                {
                    book[arr[l]]--;diff--;
                    l++;
                }
                else
                {
                    book[arr[l]]--;l++;
                }
            }
        }
        else
        {
            book[arr[r]]++;
            r++;
        }
         if(r-l+1>maks)
        {
            maks=r-l+1;
            maxl=l;
            maxr=r;
        }
    }
    printf("%ld %ld",maxl+1,maxr+1);

    return 0;
}


#include <iostream>
#include <cstdio>
using namespace std;

int main()
{
    long int n,k;
    scanf("%ld%ld",&n,&k);
    long int arr[n];
    long int diff=0;
    long int book[100005];for(long int i=0;i<100005;i++)book[i]=0;
    for(long int i=0;i<n;i++){scanf("%ld",arr+i);/*if(book[arr[i]]==0)diff++;book[arr[i]]++;*/}
    long int l=0,r=0;
    book[arr[0]]++;diff=1;
    long int maxl,maxr,maks=0;
    while(r<n-1)
    {
        if(book[arr[r+1]]==0)
        {
            if(diff<k)
            {
                r++;
                book[arr[r]]++;
                diff++;
            }
            else
            {
                if(book[arr[l]]==1)
                {
                    book[arr[l]]--;diff--;
                    l++;
                }
                else
                {
                    book[arr[l]]--;l++;
                }
            }
        }
        else
        {
            r++;
        }
         if(r-l+1>maks)
        {
            maks=r-l+1;
            maxl=l;
            maxr=r;
        }
    }
    printf("%ld %ld",maxl+1,maxr+1);

    return 0;
}


#include <iostream>
#include <cstdio>
using namespace std;

int main()
{
    long int n,k;
    scanf("%ld%ld",&n,&k);
    long int arr[n];
    long int diff=0;
    long int book[100005];for(long int i=0;i<100005;i++)book[i]=0;
    for(long int i=0;i<n;i++){scanf("%ld",arr+i);if(book[arr[i]]==0)diff++;book[arr[i]]++;}
    long int l=0,r=n-1;
    while((diff>k)&&(l<r))
    {
        if(book[arr[l]]==1)
        {
            diff--;
            l++;
        }
        else if(book[arr[r]]==1)
        {
            diff--;
            r--;
        }
        else {book[arr[r]]--;r--;}
    }
    printf("%ld %ld",l+1,r+1);

    return 0;
}


#include <iostream>
#include <cstdio>
using namespace std;

int main()
{
    long int n,k;
    scanf("%ld%ld",&n,&k);
    long int arr[n];
    long int diff=0;
    long int book[1000005];for(long int i=0;i<1000005;i++)book[i]=0;
    for(long int i=0;i<n;i++){scanf("%ld",arr+i);/*if(book[arr[i]]==0)diff++;book[arr[i]]++;*/}
    long int l=0,r=0;
    book[arr[0]]++;diff=1;
    long int maxl,maxr,maks=0;
    while(r<n-1)
    {
        if(book[arr[r+1]]==0)
        {
            if(diff<k)
            {
                r++;
                book[arr[r]]++;
                diff++;
            }
            else
            {
                if(book[arr[l]]==1)
                {
                    book[arr[l]]--;diff--;
                    l++;
                }
                else
                {
                    book[arr[l]]--;l++;
                }
            }
        }
        else
        {
            r++;
        }
         if(r-l+1>maks)
        {
            maks=r-l+1;
            maxl=l;
            maxr=r;
        }
    }
    printf("%ld %ld",maxl+1,maxr+1);

    return 0;
}


#include<iostream>
using namespace std;
int b[10000001],a[100001],ll,rr,l,i,n,k,cn,mx;
int main()
{
    cin>>n>>k;
    for(i=0;i<n;i++){
        cin>>a[i];
        if(!b[a[i]])cn++;
        b[a[i]]++;
        while(cn>k){
            b[a[l]]--;
            if(!b[a[l]])cn--;
            l++;
        }
        if(i-l+1>mx){
            mx=i-l+1;
            ll=l;
            rr=i;
        }
    }
    cout<<ll<<' '<<rr;
}


#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
const int N=2*1e5+10;
typedef long long ll;
int num[N];
ll fac[N];
ll cal(ll x,ll k)
{
    ll ans=1;
    while(k)
    {
        if(k&1)
        {
            ans*=x;
            ans%=mod;
        }
        x*=x;
        x%=mod;
        k>>=1;
    }
    return ans;
}
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        memset(num,0,sizeof(num));
        int a;
        for(int i=0;i<n;i++)
        {
            scanf("%d",&a);
            num[a]++;
        }
        fac[0]=1;
        for(int i=1;i<N;i++)
            fac[i]=fac[i-1]*(num[i]+1)%(mod-1);
        ll ans=1,temp=1;
        for(int i=N;i>0;i--)
        {
            ans=ans*cal(i,fac[i-1]*temp%(mod-1)*((num[i]+1)*(ll)num[i]/2%(mod-1))%(mod-1))%mod;
            temp=temp*(num[i]+1)%(mod-1);
        }
        printf("%lld\n",ans);
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
const int maxn=511111;
int num[maxn],vis[maxn*10];
int main()
{
    int n,k;
    while(scanf("%d%d",&n,&k)!=EOF)
    {
        int l=1,L=1e9,R=1e9;
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&num[i]);
        }
        int ans=0,res=0;
        for(int i=1;i<=n;i++)
        {
            if(!vis[num[i]])
                ans++;
            vis[num[i]]++;
            if(ans>k)
            {
                if(i-l>res)
                {
                    res=i-l;
                     L=l;
                     R=i-1;
                }
                vis[num[l]]--;
                while(vis[num[l]])
                {
                    l++;
                    vis[num[l]]--;
                }
                l++;
                ans--;
            }
        }
        if(L==1e9&&R==1e9)
        {
            printf("%d %d\n",1,n);
            return 0;
        }
        printf("%d %d\n",L,R);
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
const int maxn=511111;
int num[maxn],vis[maxn*10];
int main()
{
    int n,k;
    while(scanf("%d%d",&n,&k)!=EOF)
    {
        int l=1,L=1e9,R=1e9;
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&num[i]);
        }
        num[n+1]=5100000;
        int ans=0,res=0;
        for(int i=1;i<=n;i++)
        {
            if(!vis[num[i]])
                ans++;
            vis[num[i]]++;
            if(ans>k)
            {
                if(i-l>res)
                {
                    res=i-l;
                     L=l;
                     R=i-1;
                }
                vis[num[l]]--;
                while(vis[num[l]])
                {
                    l++;
                    vis[num[l]]--;
                }
                l++;
                ans--;
            }
        }
        if(ans<=k&&n-l+1>res)
        {
            L=l;
            R=n;
        }
        if(L==1e9&&R==1e9)
        {
            printf("%d %d\n",1,n);
            return 0;
        }
        printf("%d %d\n",L,R);
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
const int maxn=511111;
int num[maxn],vis[maxn*10];
int main()
{
    int n,k;
    while(scanf("%d%d",&n,&k)!=EOF)
    {
        int l,L=1e9,R=1e9;
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&num[i]);
        }
        int ans=0,res=0;
        for(int i=1;i<=n;i++)
        {
            if(!vis[num[i]])
                ans++;
            vis[num[i]]++;
            if(ans>k)
            {
                if(i-l>res)
                {
                    res=i-l;
                     L=l;
                     R=i-1;
                }
                vis[num[l]]--;
                while(vis[num[l]])
                {
                    l++;
                    vis[num[l]]--;
                }
                ans--;
            }
        }
        if(L==1e9&&R==1e9)
        {
            printf("%d %d\n",1,n);
            return 0;
        }
        printf("%d %d\n",L,R);
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
const int maxn=511111;
int num[maxn],vis[maxn*10];
int main()
{
    int n,k;
    while(scanf("%d%d",&n,&k)!=EOF)
    {
        int l=1,L=1e9,R=1e9;
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&num[i]);
        }
        num[n+1]=5100000;
        int ans=0,res=0;
        for(int i=1;i<=n;i++)
        {
            if(!vis[num[i]])
                ans++;
            vis[num[i]]++;
            if(ans>k)
            {
                if(i-l>res)
                {
                    res=i-l;
                     L=l;
                     R=i-1;
                }
                vis[num[l]]--;
                while(vis[num[l]])
                {
                    l++;
                    vis[num[l]]--;
                }
                l++;
                ans--;
            }
        }
        if(ans<=k&&n-l>res)
        {
            L=l;
            R=n;
        }
        if(L==1e9&&R==1e9)
        {
            printf("%d %d\n",1,n);
            return 0;
        }
        printf("%d %d\n",L,R);
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
const int maxn=511111;
int num[maxn],vis[maxn*10];
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    {
        int l,L=1e9,R=1e9;
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&num[i]);
        }
        int ans=0,res=0;
        for(int i=1;i<=n;i++)
        {
            if(!vis[num[i]])
                ans++;
            vis[num[i]]++;
            if(ans>k)
            {
                if(i-l>res)
                {
                    res=i-l;
                     L=l;
                     R=i-1;
                }
                vis[num[l]]--;
                while(vis[num[l]])
                {
                    l++;
                    vis[num[l]]--;
                }
                ans--;
            }
        }
        if(L==1e9&&R==1e9)
        {
            printf("%d %d\n",1,n);
            return 0;
        }
        printf("%d %d\n",L,R);
    }
    return 0;
}


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

bool vis[1000010] = {0};
bool viss[1000010] = {0};
struct node
{
    int l, r, len;
} a[101010];

bool cmp(node xx, node yy)
{
    return xx.len > yy.len;
}

int main()
{
    queue<int> q;
    int dif = 0;
    int l = 1,r, tmp, len = 0, cnt = 0, num = 0;
    int n, k, x;
    cnt = 0;
    scanf("%d %d", &n, &k);
    for(int i = 1; i <= n; i ++)
    {
        scanf("%d", &x);
        if(!viss[x])
        {
            viss[x] = true;
            dif ++;
        }
        if(!vis[x])
        {
            if(cnt == k)
            {
                tmp = q.front();
                while(q.size() && q.front() == tmp)
                {
                    vis[q.front()] = false;
                    q.pop();
                    l++;
                }
                vis[x] = true;
                q.push(x);
                r = i;
                num ++;
                a[num].l = l;
                a[num].r = i;
                a[num].len = a[num].r-a[num].l+1;
            }
            else
            {
                cnt ++;
                vis[x] = true;
                q.push(x);
            }
        }
        else if(vis[x])
        {
            q.push(x);
            if(cnt == k)
            {
                num ++;
                a[num].l = l;
                a[num].r = i;
                a[num].len = a[num].r-a[num].l+1;
            }
        }
    }
    if(dif<=k)
    {
        printf("%d %d\n", 1, n);
        return 0;
    }
    sort(a+1,a+num+1, cmp);
    printf("%d %d\n", a[1].l, a[1].r);
    return 0;
}


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

bool vis[1000010] = {0};
bool viss[1000010] = {0};
struct node
{
    int l, r, len;
} a[101010];

bool cmp(node xx, node yy)
{
    return xx.len > yy.len;
}

int main()
{
    queue<int> q;
    int dif = 0;
    int l = 1, tmp, cnt = 0, num = 0;
    int n, k, x;
    cnt = 0;
    scanf("%d %d", &n, &k);
    for(int i = 1; i <= n; i ++)
    {
        scanf("%d", &x);
        if(!viss[x])
        {
            viss[x] = true;
            dif ++;
        }
        if(!vis[x])
        {
            if(cnt == k)
            {
                tmp = q.front();
                vis[tmp] = false;
                while(q.size() && q.front() == tmp)
                {
                    q.pop();
                    l++;
                }
                vis[x] = true;
                q.push(x);
                num ++;
                a[num].l = l;
                a[num].r = i;
                a[num].len = a[num].r-a[num].l+1;
            }
            else
            {
                cnt ++;
                vis[x] = true;
                q.push(x);
                if(cnt == k)
                {
                    num ++;
                    a[num].l = l;
                    a[num].r = i;
                    a[num].len = a[num].r - a[num].l+1;
                }
            }
        }
        else if(vis[x])
        {
            q.push(x);
            if(cnt == k)
            {
                num ++;
                a[num].l = l;
                a[num].r = i;
                a[num].len = a[num].r-a[num].l+1;
            }
        }
    }
    if(dif<=k)
    {
        printf("%d %d\n", 1, n);
        return 0;
    }
    sort(a+1,a+num+1, cmp);
    printf("%d %d\n", a[1].l, a[1].r);
    return 0;
}

//10
//3
//1 1 2 2 2 3 4 5 5 5


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

int vis[1000010] = {0};
bool viss[1000010] = {0};
struct node
{
    int l, r, len;
} a[101010];

bool cmp(node xx, node yy)
{
    return xx.len > yy.len;
}

int main()
{
    queue<int> q;
    int dif = 0;
    int l = 1, tmp, cnt = 0, num = 0;
    int n, k, x;
    cnt = 0;
    scanf("%d %d", &n, &k);
    for(int i = 1; i <= n; i ++)
    {
        scanf("%d", &x);
        if(!viss[x])
        {
            viss[x] = true;
            dif ++;
        }
        if(!vis[x])
        {
            if(cnt == k)
            {
                tmp = q.front();
                while(q.size() && vis[tmp])
                {
                    vis[q.front()] --;
                    if(vis[q.front()] == 0)
                    {
                        cnt --;
                    }
                    q.pop();
                    l++;
                }
                vis[x] ++;
                cnt ++;
                q.push(x);
                if(cnt == k)
                {
                    num ++;
                    a[num].l = l;
                    a[num].r = i;
                    a[num].len = a[num].r-a[num].l+1;
                }
            }
            else
            {
                cnt ++;
                vis[x] ++;
                q.push(x);
                if(cnt == k)
                {
                    num ++;
                    a[num].l = l;
                    a[num].r = i;
                    a[num].len = a[num].r - a[num].l + 1;
                }
            }
        }
        else if(vis[x])
        {
            q.push(x);
            if(cnt == k)
            {
                vis[x] ++;
                num ++;
                a[num].l = l;
                a[num].r = i;
                a[num].len = a[num].r-a[num].l+1;
            }
        }
    }
    if(dif <= k)
    {
        printf("%d %d\n", 1, n);
        return 0;
    }
    sort(a+1,a+num+1, cmp);
    printf("%d %d\n", a[1].l, a[1].r);
    return 0;
}

//10
//3
//1 1 2 2 2 3 4 5 5 5

//9 3
//5 6 1 2 5 5 1 6 5


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

int vis[1000010] = {0};
bool viss[1000010] = {0};
struct node
{
    int l, r, len;
} a[101010];

bool cmp(node xx, node yy)
{
    return xx.len > yy.len;
}

int main()
{
    queue<int> q;
    int dif = 0;
    int l = 1, tmp, cnt = 0, num = 0;
    int n, k, x;
    cnt = 0;
    scanf("%d %d", &n, &k);
    for(int i = 1; i <= n; i ++)
    {
        scanf("%d", &x);
        if(!viss[x])
        {
            viss[x] = true;
            dif ++;
        }
        if(vis[x] == 0)
        {
            if(cnt == k)
            {
                if(vis[x]==0)
                {
                    tmp = q.front();
                    while(q.size() )
                    {
                        vis[tmp] --;
                        q.pop();
                        l++;
                        if(vis[tmp] == 0)
                        {
                            cnt --;
                            break;
                        }
                        tmp = q.front();
                    }
                }
                // cout << vis[tmp]<< endl;
                if(vis[x] == 0)
                {
                    cnt++;
                }
                vis[x] ++;
                q.push(x);
                if(cnt == k)
                {
                    num ++;
                    a[num].l = l;
                    a[num].r = i;
                    a[num].len = a[num].r-a[num].l+1;
                }
            }
            else
            {
                cnt ++;
                vis[x] ++;
                q.push(x);
                if(cnt == k)
                {
                    num ++;
                    a[num].l = l;
                    a[num].r = i;
                    a[num].len = a[num].r - a[num].l+1;
                }
            }
        }
        else if(vis[x] > 0)
        {
            q.push(x);
            vis[x] ++;
            //cout << x << " " << vis[x] << endl;
            if(cnt == k)
            {
                num ++;
                a[num].l = l;
                a[num].r = i;
                a[num].len = a[num].r-a[num].l+1;
            }
        }
    }
    if(dif<=k)
    {
        printf("%d %d\n", 1, n);
        return 0;
    }
    sort(a+1,a+num+1, cmp);
    printf("%d %d\n", a[1].l, a[1].r);
    return 0;
}

//10
//3
//1 1 2 2 2 3 4 5 5 5


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

bool vis[1000010] = {0};
bool viss[1000010] = {0};
struct node
{
    int l, r, len;
} a[101010];

bool cmp(node xx, node yy)
{
    return xx.len > yy.len;
}

int main()
{
    queue<int> q;
    int dif = 0;
    int l = 1,r, tmp, len = 0, cnt = 0, num = 0;
    int n, k, x;
    cnt = 0;
    scanf("%d %d", &n, &k);
    for(int i = 1; i <= n; i ++)
    {
        scanf("%d", &x);
        if(!viss[x])
        {
            viss[x] = true;
            dif ++;
        }
        if(!vis[x])
        {
            if(cnt == k)
            {
                tmp = q.front();
                vis[tmp] = false;
                while(q.size() && q.front() == tmp)
                {
                    q.pop();
                    l++;
                }
                vis[x] = true;
                q.push(x);
                r = i;
                num ++;
                a[num].l = l;
                a[num].r = i;
                a[num].len = a[num].r-a[num].l+1;
            }
            else
            {
                cnt ++;
                vis[x] = true;
                q.push(x);
                if(cnt == k)
                {
                    num ++;
                    a[num].l = l;
                    a[num].r = i;
                    a[num].len = a[num].r - a[num].l+1;
                }
            }
        }
        else if(vis[x])
        {
            q.push(x);
            if(cnt == k)
            {
                num ++;
                a[num].l = l;
                a[num].r = i;
                a[num].len = a[num].r-a[num].l+1;
            }
        }
    }
    if(dif<=k)
    {
        printf("%d %d\n", 1, n);
        return 0;
    }
    sort(a+1,a+num+1, cmp);
    printf("%d %d\n", a[1].l, a[1].r);
    return 0;
}

//10
//3
//1 1 2 2 2 3 4 5 5 5