Problem:
w
本の縦棒からなり，高さ(横棒を追加することのできる段数) が
h
のあみだくじがある．
w
は偶数である．このあみだくじの横棒を追加する場所の候補のうち上から
a
番目，左から
b
番目を
(a, b)
という．(
(a, b)
に横棒を追加した場合，上から
a
段目で左から
b
番目と
b+1
番目の縦棒が結ばれる．) このような場所は合計
h(w −1)
箇所(1 ≤
a
≤
h
, 1 ≤
b
≤
w
− 1) 存在する．
すぬけ君は，
a
≡
b
(mod 2) をみたす場所
(a, b)
に全て横棒を追加した．次に，すぬけ君は，
(a
1
, b
1
), . . . , (a
n
, b
n
)
の場所の横棒を消した．上端で左から
i
番目を選んだとき下端で左から何番目になるか，というのを全て求めよ．
Constraints
1 ≤
h, w,  n
≤ 200000
w
は偶数
1 ≤
a
i
≤
h
1 ≤
b
i
≤
w
− 1
a
i
≡
b
i
(mod 2)
(a
i
, b
i
)
=
(a
j
, b
j
)
となるような相異なる
i, j
は存在しない
Input
h
w
n
a
1
b
1
. . .
a
n
b
n
Output
w
行出力せよ．
i
行目には，上端で左から
i
番目を選んだとき下端で左から何番目になるかを出力せよ．
Sample Input 1
4 4 1
3 3
Sample Output 1
2
3
4
1
図1: たとえば，上端で左端の縦棒を選ぶと，(1, 1), (2, 2), (4, 2) を通って下端で左から二番目の縦棒にたどり着く．
Sample Input 2
10 6 10
10 4
4 4
5 1
4 2
7 3
1 3
2 4
8 2
7 5
7 1
Sample Output 2
1
4
3
2
5
6

Submitted solutions:

code_snippet: // AOJ #2632
// Dense Amidakuji 2025.2.2

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

#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)

int Cin() {  // 整数の入力
	int n = 0, c = gc();
//	if (c == '-') {	c = gc();
//		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
//		return -n;
//	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

void Cout(int n) { // 整数の表示（出力）
	char b[30];
	if (!n) pc('0');
	else {
//		if (n < 0) pc('-'), n = -n;
		int i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(b[i]);
	}
	pc('\n');
}

int W;
 
inline int S_odd(int x) { return (x & 1) ? x + 1 : x - 1; }
 
inline int S_even(int x, int W) {
    if(x == 1 || x == W) return x;
    return (x & 1) ? x - 1 : x + 1;
}
 
inline int P_odd (int x, int W) {
    if(x & 1){
        int cand = x + 2;
        return (cand <= W ? cand : W);
    } else {
        int cand = x - 2;
        return (cand >= 1 ? cand : 1);
    }
}
 
int maxLog;
vector<vector<int>> jump;
 
void buildJumpTable(int W) {
    ::W = W;
    maxLog = 0;
    while((1 << maxLog) <= 100000) maxLog++;
    jump.assign(maxLog, vector<int>(W+1, 0));
    for (int x = 1; x <= W; x++){
        jump[0][x] = P_odd(x, W);
    }
    for (int k = 1; k < maxLog; k++){
        for (int x = 1; x <= W; x++){
            jump[k][x] = jump[k-1][ jump[k-1][x] ];
        }
    }
}
 
int applyP_odd(int x, int m) {
    int cur = x;
    for (int k = 0; k < maxLog; k++){
        if(m & (1 << k)) cur = jump[k][cur];
    }
    return cur;
}
 
int F_odd(int d, int x, int W) {
    if(d <= 0) return x;
    int m = d >> 1;
    int tmp = applyP_odd(x, m);
    return (d % 2 == 0 ? tmp : S_odd(tmp));
}
 
int F_even(int d, int x, int W) {
    if(d <= 0) return x;
    int first = S_even(x, W);
    return F_odd(d - 1, first, W);
}
 
struct Removal { int a, b; };
 
int main(){
    int h = Cin(), w = Cin(), n = Cin();

    vector<Removal> rems(n);
    for (int i = 0; i < n; i++){
        rems[i].a = Cin(), rems[i].b = Cin();
    }
    sort(rems.begin(), rems.end(), [](const Removal &r1, const Removal &r2){
        return r1.a > r2.a;
    });
 
    buildJumpTable(w);
 
    vector<int> Q(w+1);
    for (int i = 1; i <= w; i++) Q[i] = i;
    for (int i = 0; i < n; i++){
        int a = rems[i].a, b = rems[i].b;
        int dprime = h - a + 1;
        int pos1, pos2;
        if(a & 1){
            pos1 = F_odd(dprime, b, w);
            pos2 = F_odd(dprime, b+1, w);
        } else {
            pos1 = F_even(dprime, b, w);
            pos2 = F_even(dprime, b+1, w);
        }
        if(pos1 != pos2) swap(Q[pos1], Q[pos2]);
    }
 
    for (int i = 1; i <= w; i++){
        int fullRes = F_odd(h, i, w);
        int finalRes = Q[fullRes];
        Cout(finalRes);
    }
    return 0;
}
accuracy: 1
time_ms: 60
memory_kb: 18560
final_rank: 16

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) sort(ALL(v)), (v).erase(unique(ALL(v)), (v).end())
#define SZ(v) (int)v.size()
#define MIN(v) *min_element(ALL(v))
#define MAX(v) *max_element(ALL(v))
#define LB(v, x) int(lower_bound(ALL(v), (x)) - (v).begin())
#define UB(v, x) int(upper_bound(ALL(v), (x)) - (v).begin())

using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long;
using i128 = __int128_t;
using u128 = __uint128_t;
const int inf = 0x3fffffff;
const ll INF = 0x1fffffffffffffff;

template <typename T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T, typename U> T ceil(T x, U y) {
    assert(y != 0);
    if (y < 0)
        x = -x, y = -y;
    return (x > 0 ? (x + y - 1) / y : x / y);
}
template <typename T, typename U> T floor(T x, U y) {
    assert(y != 0);
    if (y < 0)
        x = -x, y = -y;
    return (x > 0 ? x / y : (x - y + 1) / y);
}
template <typename T> int popcnt(T x) {
    return __builtin_popcountll(x);
}
template <typename T> int topbit(T x) {
    return (x == 0 ? -1 : 63 - __builtin_clzll(x));
}
template <typename T> int lowbit(T x) {
    return (x == 0 ? -1 : __builtin_ctzll(x));
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "P(" << p.first << ", " << p.second << ")";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end())
            os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const set<T> &set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end())
            os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
#ifdef LOCAL
#define show(...) _show(0, #__VA_ARGS__, __VA_ARGS__)
#else
#define show(...) true
#endif
template <typename T> void _show(int i, T name) {
    cerr << '\n';
}
template <typename T1, typename T2, typename... T3>
void _show(int i, const T1 &a, const T2 &b, const T3 &...c) {
    for (; a[i] != ',' && a[i] != '\0'; i++)
        cerr << a[i];
    cerr << ":" << b << " ";
    _show(i + 1, a, c...);
}

/**
 * @brief template
 */

int main() {
    int N, M, K;
    cin >> N >> M >> K;
    vector<pair<int,pair<int,int>>> V;
    auto Calc = [&](int X, int Y) -> int {
        if ((X+Y) % 2 == 0) return ((Y-X)%M+M)%M;
        else return (X+Y)%M;
    };
    rep(i,0,N) {
        if (i % 2 == 0) continue;
        V.push_back({i,{Calc(i,0),Calc(i,M-1)}});
    }
    rep(i,0,K) {
        int A, B;
        cin >> A >> B;
        A--, B--;
        V.push_back({A,{Calc(A,B),Calc(A,B+1)}});
    }
    sort(ALL(V));
    vector<int> ANS(M);
    iota(ALL(ANS),0);
    rep(i,0,V.size()) {
        swap(ANS[V[i].second.first],ANS[V[i].second.second]);
    }
    vector<int> ANS2(M);
    rep(i,0,M) ANS2[ANS[Calc(N,i)]] = i;
    rep(i,0,M) cout << ANS2[i] + 1 << endl;
}
accuracy: 1
time_ms: 220
memory_kb: 11152
final_rank: 15

code_snippet: #include <bits/stdc++.h>

#ifdef _MSC_VER
#  include <intrin.h>
#else
#  include <x86intrin.h>
#endif

#include <limits>
#include <type_traits>

namespace suisen {
// ! utility
template <typename ...Types>
using constraints_t = std::enable_if_t<std::conjunction_v<Types...>, std::nullptr_t>;
template <bool cond_v, typename Then, typename OrElse>
constexpr decltype(auto) constexpr_if(Then&& then, OrElse&& or_else) {
    if constexpr (cond_v) {
        return std::forward<Then>(then);
    } else {
        return std::forward<OrElse>(or_else);
    }
}

// ! function
template <typename ReturnType, typename Callable, typename ...Args>
using is_same_as_invoke_result = std::is_same<std::invoke_result_t<Callable, Args...>, ReturnType>;
template <typename F, typename T>
using is_uni_op = is_same_as_invoke_result<T, F, T>;
template <typename F, typename T>
using is_bin_op = is_same_as_invoke_result<T, F, T, T>;

template <typename Comparator, typename T>
using is_comparator = std::is_same<std::invoke_result_t<Comparator, T, T>, bool>;

// ! integral
template <typename T, typename = constraints_t<std::is_integral<T>>>
constexpr int bit_num = std::numeric_limits<std::make_unsigned_t<T>>::digits;
template <typename T, unsigned int n>
struct is_nbit { static constexpr bool value = bit_num<T> == n; };
template <typename T, unsigned int n>
static constexpr bool is_nbit_v = is_nbit<T, n>::value;

// ?
template <typename T>
struct safely_multipliable {};
template <>
struct safely_multipliable<int> { using type = long long; };
template <>
struct safely_multipliable<long long> { using type = __int128_t; };
template <>
struct safely_multipliable<unsigned int> { using type = unsigned long long; };
template <>
struct safely_multipliable<unsigned long int> { using type = __uint128_t; };
template <>
struct safely_multipliable<unsigned long long> { using type = __uint128_t; };
template <>
struct safely_multipliable<float> { using type = float; };
template <>
struct safely_multipliable<double> { using type = double; };
template <>
struct safely_multipliable<long double> { using type = long double; };
template <typename T>
using safely_multipliable_t = typename safely_multipliable<T>::type;

template <typename T, typename = void>
struct rec_value_type {
    using type = T;
};
template <typename T>
struct rec_value_type<T, std::void_t<typename T::value_type>> {
    using type = typename rec_value_type<typename T::value_type>::type;
};
template <typename T>
using rec_value_type_t = typename rec_value_type<T>::type;

} // namespace suisen

// ! type aliases
using i128 = __int128_t;
using u128 = __uint128_t;

template <typename T>
using pq_greater = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <typename T, typename U>
using umap = std::unordered_map<T, U>;

// ! macros (capital: internal macro)
#define OVERLOAD2(_1,_2,name,...) name
#define OVERLOAD3(_1,_2,_3,name,...) name
#define OVERLOAD4(_1,_2,_3,_4,name,...) name

#define REP4(i,l,r,s)  for(std::remove_reference_t<std::remove_const_t<decltype(r)>>i=(l);i<(r);i+=(s))
#define REP3(i,l,r)    REP4(i,l,r,1)
#define REP2(i,n)      REP3(i,0,n)
#define REPINF3(i,l,s) for(std::remove_reference_t<std::remove_const_t<decltype(l)>>i=(l);;i+=(s))
#define REPINF2(i,l)   REPINF3(i,l,1)
#define REPINF1(i)     REPINF2(i,0)
#define RREP4(i,l,r,s) for(std::remove_reference_t<std::remove_const_t<decltype(r)>>i=(l)+fld((r)-(l)-1,s)*(s);i>=(l);i-=(s))
#define RREP3(i,l,r)   RREP4(i,l,r,1)
#define RREP2(i,n)     RREP3(i,0,n)

#define rep(...)    OVERLOAD4(__VA_ARGS__, REP4   , REP3   , REP2   )(__VA_ARGS__)
#define rrep(...)   OVERLOAD4(__VA_ARGS__, RREP4  , RREP3  , RREP2  )(__VA_ARGS__)
#define repinf(...) OVERLOAD3(__VA_ARGS__, REPINF3, REPINF2, REPINF1)(__VA_ARGS__)

#define CAT_I(a, b) a##b
#define CAT(a, b) CAT_I(a, b)
#define UNIQVAR(tag) CAT(tag, __LINE__)
#define loop(n) for (std::remove_reference_t<std::remove_const_t<decltype(n)>> UNIQVAR(loop_variable) = n; UNIQVAR(loop_variable) --> 0;)

#define all(iterable) std::begin(iterable), std::end(iterable)
#define input(type, ...) type __VA_ARGS__; read(__VA_ARGS__)

#ifdef LOCAL
#  define debug(...) debug_internal(#__VA_ARGS__, __VA_ARGS__)

template <class T, class... Args>
void debug_internal(const char* s, T&& first, Args&&... args) {
    constexpr const char* prefix = "[\033[32mDEBUG\033[m] ";
    constexpr const char* open_brakets = sizeof...(args) == 0 ? "" : "(";
    constexpr const char* close_brakets = sizeof...(args) == 0 ? "" : ")";
    std::cerr << prefix << open_brakets << s << close_brakets << ": " << open_brakets << std::forward<T>(first);
    ((std::cerr << ", " << std::forward<Args>(args)), ...);
    std::cerr << close_brakets << "\n";
}

#else
#  define debug(...) void(0)
#endif

// ! I/O utilities

// __int128_t
std::ostream& operator<<(std::ostream& dest, __int128_t value) {
    std::ostream::sentry s(dest);
    if (s) {
        __uint128_t tmp = value < 0 ? -value : value;
        char buffer[128];
        char* d = std::end(buffer);
        do {
            --d;
            *d = "0123456789"[tmp % 10];
            tmp /= 10;
        } while (tmp != 0);
        if (value < 0) {
            --d;
            *d = '-';
        }
        int len = std::end(buffer) - d;
        if (dest.rdbuf()->sputn(d, len) != len) {
            dest.setstate(std::ios_base::badbit);
        }
    }
    return dest;
}
// __uint128_t
std::ostream& operator<<(std::ostream& dest, __uint128_t value) {
    std::ostream::sentry s(dest);
    if (s) {
        char buffer[128];
        char* d = std::end(buffer);
        do {
            --d;
            *d = "0123456789"[value % 10];
            value /= 10;
        } while (value != 0);
        int len = std::end(buffer) - d;
        if (dest.rdbuf()->sputn(d, len) != len) {
            dest.setstate(std::ios_base::badbit);
        }
    }
    return dest;
}

// pair
template <typename T, typename U>
std::ostream& operator<<(std::ostream& out, const std::pair<T, U>& a) {
    return out << a.first << ' ' << a.second;
}
// tuple
template <unsigned int N = 0, typename ...Args>
std::ostream& operator<<(std::ostream& out, const std::tuple<Args...>& a) {
    if constexpr (N >= std::tuple_size_v<std::tuple<Args...>>) {
        return out;
    } else {
        out << std::get<N>(a);
        if constexpr (N + 1 < std::tuple_size_v<std::tuple<Args...>>) {
            out << ' ';
        }
        return operator<<<N + 1>(out, a);
    }
}
// vector
template <typename T>
std::ostream& operator<<(std::ostream& out, const std::vector<T>& a) {
    for (auto it = a.begin(); it != a.end();) {
        out << *it;
        if (++it != a.end()) out << ' ';
    }
    return out;
}
// array
template <typename T, size_t N>
std::ostream& operator<<(std::ostream& out, const std::array<T, N>& a) {
    for (auto it = a.begin(); it != a.end();) {
        out << *it;
        if (++it != a.end()) out << ' ';
    }
    return out;
}
inline void print() { std::cout << '\n'; }
template <typename Head, typename... Tail>
inline void print(const Head& head, const Tail &...tails) {
    std::cout << head;
    if (sizeof...(tails)) std::cout << ' ';
    print(tails...);
}
template <typename Iterable>
auto print_all(const Iterable& v, std::string sep = " ", std::string end = "\n") -> decltype(std::cout << *v.begin(), void()) {
    for (auto it = v.begin(); it != v.end();) {
        std::cout << *it;
        if (++it != v.end()) std::cout << sep;
    }
    std::cout << end;
}

__int128_t parse_i128(std::string& s) {
    __int128_t ret = 0;
    for (int i = 0; i < int(s.size()); i++) if ('0' <= s[i] and s[i] <= '9') ret = 10 * ret + s[i] - '0';
    if (s[0] == '-') ret = -ret;
    return ret;
}
__uint128_t parse_u128(std::string& s) {
    __uint128_t ret = 0;
    for (int i = 0; i < int(s.size()); i++) if ('0' <= s[i] and s[i] <= '9') ret = 10 * ret + s[i] - '0';
    return ret;
}
// __int128_t
std::istream& operator>>(std::istream& in, __int128_t& v) {
    std::string s;
    in >> s;
    v = parse_i128(s);
    return in;
}
// __uint128_t
std::istream& operator>>(std::istream& in, __uint128_t& v) {
    std::string s;
    in >> s;
    v = parse_u128(s);
    return in;
}
// pair
template <typename T, typename U>
std::istream& operator>>(std::istream& in, std::pair<T, U>& a) {
    return in >> a.first >> a.second;
}
// tuple
template <unsigned int N = 0, typename ...Args>
std::istream& operator>>(std::istream& in, std::tuple<Args...>& a) {
    if constexpr (N >= std::tuple_size_v<std::tuple<Args...>>) {
        return in;
    } else {
        return operator>><N + 1>(in >> std::get<N>(a), a);
    }
}
// vector
template <typename T>
std::istream& operator>>(std::istream& in, std::vector<T>& a) {
    for (auto it = a.begin(); it != a.end(); ++it) in >> *it;
    return in;
}
// array
template <typename T, size_t N>
std::istream& operator>>(std::istream& in, std::array<T, N>& a) {
    for (auto it = a.begin(); it != a.end(); ++it) in >> *it;
    return in;
}
template <typename ...Args>
void read(Args &...args) {
    (std::cin >> ... >> args);
}

// ! integral utilities

// Returns pow(-1, n)
template <typename T>
constexpr inline int pow_m1(T n) {
    return -(n & 1) | 1;
}
// Returns pow(-1, n)
template <>
constexpr inline int pow_m1<bool>(bool n) {
    return -int(n) | 1;
}

// Returns floor(x / y)
template <typename T>
constexpr inline T fld(const T x, const T y) {
    return (x ^ y) >= 0 ? x / y : (x - (y + pow_m1(y >= 0))) / y;
}
template <typename T>
constexpr inline T cld(const T x, const T y) {
    return (x ^ y) <= 0 ? x / y : (x + (y + pow_m1(y >= 0))) / y;
}

template <typename T, suisen::constraints_t<suisen::is_nbit<T, 16>> = nullptr>
__attribute__((target("popcnt"))) constexpr inline int popcount(const T x) { return _mm_popcnt_u32(x); }
template <typename T, suisen::constraints_t<suisen::is_nbit<T, 32>> = nullptr>
__attribute__((target("popcnt"))) constexpr inline int popcount(const T x) { return _mm_popcnt_u32(x); }
template <typename T, suisen::constraints_t<suisen::is_nbit<T, 64>> = nullptr>
__attribute__((target("popcnt"))) constexpr inline int popcount(const T x) { return _mm_popcnt_u64(x); }
template <typename T, suisen::constraints_t<suisen::is_nbit<T, 16>> = nullptr>
constexpr inline int count_lz(const T x) { return x ? __builtin_clz(x) : suisen::bit_num<T>; }
template <typename T, suisen::constraints_t<suisen::is_nbit<T, 32>> = nullptr>
constexpr inline int count_lz(const T x) { return x ? __builtin_clz(x) : suisen::bit_num<T>; }
template <typename T, suisen::constraints_t<suisen::is_nbit<T, 64>> = nullptr>
constexpr inline int count_lz(const T x) { return x ? __builtin_clzll(x) : suisen::bit_num<T>; }
template <typename T, suisen::constraints_t<suisen::is_nbit<T, 16>> = nullptr>
constexpr inline int count_tz(const T x) { return x ? __builtin_ctz(x) : suisen::bit_num<T>; }
template <typename T, suisen::constraints_t<suisen::is_nbit<T, 32>> = nullptr>
constexpr inline int count_tz(const T x) { return x ? __builtin_ctz(x) : suisen::bit_num<T>; }
template <typename T, suisen::constraints_t<suisen::is_nbit<T, 64>> = nullptr>
constexpr inline int count_tz(const T x) { return x ? __builtin_ctzll(x) : suisen::bit_num<T>; }
template <typename T>
constexpr inline int floor_log2(const T x) { return suisen::bit_num<T> -1 - count_lz(x); }
template <typename T>
constexpr inline int ceil_log2(const T x) { return floor_log2(x) + ((x & -x) != x); }
template <typename T>
constexpr inline int kth_bit(const T x, const unsigned int k) { return (x >> k) & 1; }
template <typename T>
constexpr inline int parity(const T x) { return popcount(x) & 1; }

// ! container

template <typename T, typename Comparator, suisen::constraints_t<suisen::is_comparator<Comparator, T>> = nullptr>
auto priqueue_comp(const Comparator comparator) {
    return std::priority_queue<T, std::vector<T>, Comparator>(comparator);
}

template <typename Iterable>
auto isize(const Iterable& iterable) -> decltype(int(iterable.size())) {
    return iterable.size();
}

template <typename T, typename Gen, suisen::constraints_t<suisen::is_same_as_invoke_result<T, Gen, int>> = nullptr>
auto generate_vector(int n, Gen generator) {
    std::vector<T> v(n);
    for (int i = 0; i < n; ++i) v[i] = generator(i);
    return v;
}
template <typename T>
auto generate_range_vector(T l, T r) {
    return generate_vector(r - l, [l](int i) { return l + i; });
}
template <typename T>
auto generate_range_vector(T n) {
    return generate_range_vector(0, n);
}

template <typename T>
void sort_unique_erase(std::vector<T>& a) {
    std::sort(a.begin(), a.end());
    a.erase(std::unique(a.begin(), a.end()), a.end());
}

template <typename InputIterator, typename BiConsumer>
auto foreach_adjacent_values(InputIterator first, InputIterator last, BiConsumer f) -> decltype(f(*first++, *last), void()) {
    if (first != last) for (auto itr = first, itl = itr++; itr != last; itl = itr++) f(*itl, *itr);
}
template <typename Container, typename BiConsumer>
auto foreach_adjacent_values(Container c, BiConsumer f) -> decltype(c.begin(), c.end(), void()) {
    foreach_adjacent_values(c.begin(), c.end(), f);
}

// ! other utilities

// x <- min(x, y). returns true iff `x` has chenged.
template <typename T>
inline bool chmin(T& x, const T& y) {
    if (y >= x) return false;
    x = y;
    return true;
}
// x <- max(x, y). returns true iff `x` has chenged.
template <typename T>
inline bool chmax(T& x, const T& y) {
    if (y <= x) return false;
    x = y;
    return true;
}

template <typename T, std::enable_if_t<std::is_integral_v<T>, std::nullptr_t> = nullptr>
std::string bin(T val, int bit_num = -1) {
    std::string res;
    if (bit_num >= 0) {
        for (int bit = bit_num; bit-- > 0;) res += '0' + ((val >> bit) & 1);
    } else {
        for (; val; val >>= 1) res += '0' + (val & 1);
        std::reverse(res.begin(), res.end());
    }
    return res;
}

template <typename T, std::enable_if_t<std::is_integral_v<T>, std::nullptr_t> = nullptr>
std::vector<T> digits_low_to_high(T val, T base = 10) {
    std::vector<T> res;
    for (; val; val /= base) res.push_back(val % base);
    if (res.empty()) res.push_back(T{ 0 });
    return res;
}
template <typename T, std::enable_if_t<std::is_integral_v<T>, std::nullptr_t> = nullptr>
std::vector<T> digits_high_to_low(T val, T base = 10) {
    auto res = digits_low_to_high(val, base);
    std::reverse(res.begin(), res.end());
    return res;
}

template <typename T>
std::string join(const std::vector<T>& v, const std::string& sep, const std::string& end) {
    std::ostringstream ss;
    for (auto it = v.begin(); it != v.end();) {
        ss << *it;
        if (++it != v.end()) ss << sep;
    }
    ss << end;
    return ss.str();
}

namespace suisen {}
using namespace suisen;
using namespace std;

struct io_setup {
    io_setup(int precision = 20) {
        std::ios::sync_with_stdio(false);
        std::cin.tie(nullptr);
        std::cout << std::fixed << std::setprecision(precision);
    }
} io_setup_{};

// ! code from here

int main() {
    input(int, h, w, n);
    vector<vector<int>> sw(h / 2 + 1);
    rep(i, n) {
        input(int, a, b);
        --a, --b;
        sw[(a + 1) / 2].push_back(b);
    }

    map<int, int> mp_e, mp_o;
    rep(i, w) {
        if (i % 2 == 0) {
            mp_e[i] = i;
        } else {
            mp_o[i] = i;
        }
    }

    auto mod_w = [&](int b) {
        return (b %= w) < 0 ? b + w : b;
    };

    rep(i, h / 2 + 1) {
        // auto dbg = [&] {
        //     vector<int> p(w);
        //     for (auto [k, v] : mp_e) {
        //         p[mod_w(k + 2 * i)] = v;
        //     }
        //     for (auto [k, v] : mp_o) {
        //         p[mod_w(k - 2 * i)] = v;
        //     }
        //     debug(i, p);
        // };
        // dbg();

        sort(all(sw[i]), [&](int b1, int b2) { return (b1 & 1) > (b2 & 1); });
        // debug(i, sw[i]);
        for (int b : sw[i]) {
            if ((b & 1) == 0) {
                int x = mod_w(b - 2 * i);
                int y = mod_w(b + 1 + 2 * i);
                assert(y != w);
                swap(mp_e[x], mp_o[y]);
            } else {
                int x = mod_w(b + 2 * i);
                int y = mod_w(b + 1 - 2 * i);
                assert(y != w);
                swap(mp_o[x], mp_e[y]);
            }
        }
        if (i != h / 2) {
            swap(mp_e[mod_w(w - 2 - 2 * i)], mp_o[mod_w(1 + 2 * i)]);
        }
    }

    int i = h / 2;
    vector<int> p(w);
    for (auto [k, v] : mp_e) {
        p[mod_w(k + 2 * i)] = v;
    }
    for (auto [k, v] : mp_o) {
        p[mod_w(k - 2 * i)] = v;
    }
    if (h % 2 == 1) {
        rep(i, w / 2) {
            swap(p[2 * i], p[2 * i + 1]);
        }
    }
    vector<int> q(w);
    rep(i, w) {
        q[p[i]] = i;
    }
    for (const auto& e : q) print(e + 1);

    return 0;
}
accuracy: 1
time_ms: 170
memory_kb: 19188
final_rank: 18

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

// template {{{
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

#define  range(i, l, r) for (i64 i = (i64)(l); i < (i64)(r); (i) += 1)
#define rrange(i, l, r) for (i64 i = (i64)(r) - 1; i >= (i64)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

constexpr i32 dx[] = {0, -1, 1, 0, -1, 1, -1, 1}; 
constexpr i32 dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

struct IoSetup { IoSetup(i32 x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != (int)v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solve() {
  int h = input(), w = input(), n = input();
  
  auto p_k = [&](int k, int i) {
    k %= 2 * w;
    int t = ((k & 1) == (i & 1) ? i - k : i + k);
    t += 2 * w;
    t %= 2 * w;
    return (t < w ? t : 2 * w - t - 1);
  };

  vector< pair<int, int> > ds(n);
  cin >> ds;

  whole(sort, ds);

  vector< int > ps(w);
  whole(iota, ps, 0);
  range(i, 0, n) {
    auto [a, b] = ds[i];
    swap(ps[p_k(a, b - 1)], ps[p_k(a, b)]);
  }

  vector< int > ans(w);
  range(i, 0, w) {
    ans[ps[p_k(h, i)]] = i + 1;
  }

  for (auto &i: ans) cout << i << endl;
}

signed main() {
  solve();
}
accuracy: 1
time_ms: 170
memory_kb: 6188
final_rank: 4

code_snippet: #include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1e18 + 10
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;

template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b; 
    return true;
  }
  return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int h,w,n;
  cin>>h>>w>>n;
  vector<int> v(w);
  vector<int> lis(w);
  int nxt=2;
  rep(i,w){
    if(i==0){v[0]=1;lis[0]=0;}
    else{
      if(nxt>w){
	nxt--;
	if(nxt>w) nxt-=2;
      }
      v[i]=nxt;
      lis[nxt-1]=i;
      if(nxt%2==0) nxt+=2;
      else nxt-=2;
    }
  }
  vector<int> now(w);
  rep(i,w) now[i]=i+1;
  vector<PII> ab(n);
  rep(i,n) cin>>ab[i].F>>ab[i].S;
  sort(ab.begin(),ab.end() );
  rep(i,n){
    int a=ab[i].F,b=ab[i].S;
    if(a%2==0){
      int x=lis[b-1],y=lis[b];
      x=(x+(a/2))%w;
      y=(y+(a/2))%w;
      swap(now[v[x]-1],now[v[y]-1]);
      //cout<<now[v[x]-1]<<" "<<now[v[y]-1]<<endl;
    }else{
      int x=lis[b-1],y=lis[b];
      x=(x+((a-1)/2))%w;
      y=(y+((a-1)/2))%w;
      //cout<<now[v[x]-1]<<" "<<now[v[y]-1]<<endl;
      swap(now[v[x]-1],now[v[y]-1]);


    }
  }
  vector<int> ans(w);
  rep(i,w){
    if(h%2==0){
      ans[now[v[(lis[i]+(h/2))%w]-1]-1]=i+1;

    }else{
      if(i%2==0) ans[now[v[(lis[i+1]+(h-1)/2)%w]-1]-1]=i+1;
      else ans[now[v[(lis[i-1]+((h-1)/2))%w]-1]-1]=i+1;
    }

  }
	  
  rep(i,w) cout<<ans[i]<<endl;
  return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 12424
final_rank: 5

code_snippet: #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
using namespace std;
using std::cout;
using std::cin;
using std::endl;
using ll=long long;
using ld=long double;
ll ILL=2167167167167167167;
const int INF=2100000000;
const ll mod=1e9+7;
#define rep(i,a) for (ll i=0;i<a;i++)
#define all(p) p.begin(),p.end()
template<class T> using _pq = priority_queue<T, vector<T>, greater<T>>;
template<class T> ll LB(vector<T> &v,T a){return lower_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> ll UB(vector<T> &v,T a){return upper_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}else return 0;}
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}else return 0;}
template<class T> void So(vector<T> &v) {sort(v.begin(),v.end());}
template<class T> void Sore(vector<T> &v) {sort(v.begin(),v.end(),[](T x,T y){return x>y;});}
void yneos(bool a){if(a) cout<<"Yes\n"; else cout<<"No\n";}
template<class T> void vec_out(vector<T> &p){for(int i=0;i<(int)(p.size());i++){if(i) cout<<" ";cout<<p[i];}cout<<"\n";}


void solve();
// oddloop
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	solve();
}

void solve(){
	int H,W,N;
	cin>>H>>W>>N;
	vector<int> p(W*2,-1);
	rep(i,W){
		if(i%2) p[W*2-i-1]=i;
		else p[i]=i;
	}
	vector<vector<int>> G(H);
	rep(i,N){
		int a,b; 
		cin>>a>>b; 
		G[a-1].push_back(b-1);
	}
	rep(i,H){/*
		rep(j,W){
		int x=(j+2*W-i%(2*W))%(2*W);
		int y=(x-j*2-1+2*W)%(2*W);
		cout<<1+max(p[x],p[y])<<" ";
		}
		cout<<"\n";*/
		for(auto x:G[i]){
			int y=(x-i%(2*W)+2*W)%(2*W);
			int z=(y+(W-1-x)*2)%(2*W);
			swap(p[y],p[z]);
			swap(p[(y+1)%(2*W)],p[(z+1)%(2*W)]);
		}
	}
	vector<int> ans(W);
	rep(i,W){
		int x=(i+2*W-H%(2*W))%(2*W);
		int y=(x-i*2-1+2*W)%(2*W);
		ans[max(p[x],p[y])]=i;
	}
	rep(i,W) cout<<ans[i]+1<<"\n";
	//vec_out(p);
}
accuracy: 1
time_ms: 50
memory_kb: 13968
final_rank: 11

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w, n;
    cin >> h >> w >> n;
    vector<vector<int>> bs(h);
    for (; n--;) {
        int a, b;
        cin >> a >> b;
        bs[--a].emplace_back(--b);
    }

    deque<int> deq0, deq1;
    for (int i = 0; i < w; i++) {
        if (i & 1)
            deq1.emplace_back(i);
        else
            deq0.emplace_back(i);
    }

    auto SWAP = [&](int a) {
        if (a & 1) {
            int x = deq0.front();
            deq0.pop_front();
            int y = deq1.back();
            deq1.pop_back();
            swap(deq0, deq1);
            for (int& b : bs[a]) swap(deq0[b >> 1], deq1[b >> 1]);
            deq0.emplace_front(x);
            deq1.emplace_back(y);
        } else {
            swap(deq0, deq1);
            for (int& b : bs[a]) swap(deq0[b >> 1], deq1[b >> 1]);
        }
    };
    for (int i = 0; i < h; i++) SWAP(i);

    vector<int> to;
    for (int i = 0; i < w / 2; i++) {
        to.emplace_back(deq0.front());
        deq0.pop_front();
        to.emplace_back(deq1.front());
        deq1.pop_front();
    }
    vector<int> ans(w);
    for (int i = 0; i < w; i++) ans[to[i]] = i;
    for (int& x : ans) cout << x + 1 << '\n';
    return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 14396
final_rank: 12

code_snippet: #define LOCAL
#include <bits/stdc++.h>
using namespace std;
#pragma region Macros
typedef long long ll;
typedef __int128_t i128;
typedef unsigned int uint;
typedef unsigned long long ull;
#define ALL(x) (x).begin(), (x).end()

template <typename T> istream& operator>>(istream& is, vector<T>& v) {
    for (T& x : v) is >> x;
    return is;
}
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    for (size_t i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "" : " ");
    }
    return os;
}
template <typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template <typename T, typename U> ostream& operator<<(ostream& os, const map<T, U>& m) {
    os << '{';
    for (auto itr = m.begin(); itr != m.end();) {
        os << '(' << itr->first << ',' << itr->second << ')';
        if (++itr != m.end()) os << ',';
    }
    os << '}';
    return os;
}
template <typename T, typename U> ostream& operator<<(ostream& os, const unordered_map<T, U>& m) {
    os << '{';
    for (auto itr = m.begin(); itr != m.end();) {
        os << '(' << itr->first << ',' << itr->second << ')';
        if (++itr != m.end()) os << ',';
    }
    os << '}';
    return os;
}
template <typename T> ostream& operator<<(ostream& os, const set<T>& s) {
    os << '{';
    for (auto itr = s.begin(); itr != s.end();) {
        os << *itr;
        if (++itr != s.end()) os << ',';
    }
    os << '}';
    return os;
}
template <typename T> ostream& operator<<(ostream& os, const multiset<T>& s) {
    os << '{';
    for (auto itr = s.begin(); itr != s.end();) {
        os << *itr;
        if (++itr != s.end()) os << ',';
    }
    os << '}';
    return os;
}
template <typename T> ostream& operator<<(ostream& os, const unordered_set<T>& s) {
    os << '{';
    for (auto itr = s.begin(); itr != s.end();) {
        os << *itr;
        if (++itr != s.end()) os << ',';
    }
    os << '}';
    return os;
}
template <typename T> ostream& operator<<(ostream& os, const deque<T>& v) {
    for (size_t i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "" : " ");
    }
    return os;
}
template <typename T, size_t N> ostream& operator<<(ostream& os, const array<T, N>& v) {
    for (size_t i = 0; i < N; i++) {
        os << v[i] << (i + 1 == N ? "" : " ");
    }
    return os;
}

template <int i, typename T> void print_tuple(ostream&, const T&) {}
template <int i, typename T, typename H, class... Args> void print_tuple(ostream& os, const T& t) {
    if (i) os << ',';
    os << get<i>(t);
    print_tuple<i + 1, T, Args...>(os, t);
}
template <typename... Args> ostream& operator<<(ostream& os, const tuple<Args...>& t) {
    os << '{';
    print_tuple<0, tuple<Args...>, Args...>(os, t);
    return os << '}';
}

void debug_out() { cerr << '\n'; }
template <class Head, class... Tail> void debug_out(Head&& head, Tail&&... tail) {
    cerr << head;
    if (sizeof...(Tail) > 0) cerr << ", ";
    debug_out(move(tail)...);
}
#ifdef LOCAL
#define debug(...)                                                                   \
    cerr << " ";                                                                     \
    cerr << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << '\n'; \
    cerr << " ";                                                                     \
    debug_out(__VA_ARGS__)
#else
#define debug(...) void(0)
#endif

template <typename T> T gcd(T x, T y) { return y != 0 ? gcd(y, x % y) : x; }
template <typename T> T lcm(T x, T y) { return x / gcd(x, y) * y; }

int topbit(signed t) { return t == 0 ? -1 : 31 - __builtin_clz(t); }
int topbit(long long t) { return t == 0 ? -1 : 63 - __builtin_clzll(t); }
int botbit(signed a) { return a == 0 ? 32 : __builtin_ctz(a); }
int botbit(long long a) { return a == 0 ? 64 : __builtin_ctzll(a); }
int popcount(signed t) { return __builtin_popcount(t); }
int popcount(long long t) { return __builtin_popcountll(t); }
bool ispow2(int i) { return i && (i & -i) == i; }
long long MSK(int n) { return (1LL << n) - 1; }

template <class T> T ceil(T x, T y) {
    assert(y >= 1);
    return (x > 0 ? (x + y - 1) / y : x / y);
}
template <class T> T floor(T x, T y) {
    assert(y >= 1);
    return (x > 0 ? x / y : (x - y + 1) / y);
}

template <class T1, class T2> inline bool chmin(T1& a, T2 b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T1, class T2> inline bool chmax(T1& a, T2 b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T> void mkuni(vector<T>& v) {
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
}
template <typename T> int lwb(const vector<T>& v, const T& x) { return lower_bound(v.begin(), v.end(), x) - v.begin(); }
#pragma endregion

const int INF = 1e9;
const long long IINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const char dir[4] = {'D', 'R', 'U', 'L'};
const long long MOD = 1000000007;
// const long long MOD = 998244353;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w, n;
    cin >> h >> w >> n;
    vector<vector<int>> bs(h);
    for (; n--;) {
        int a, b;
        cin >> a >> b;
        bs[--a].emplace_back(--b);
    }

    deque<int> deq0, deq1;
    for (int i = 0; i < w; i++) {
        if (i & 1)
            deq1.emplace_back(i);
        else
            deq0.emplace_back(i);
    }

    auto SWAP = [&](int a) {
        if (a & 1) {
            int x = deq0.front();
            deq0.pop_front();
            int y = deq1.back();
            deq1.pop_back();
            swap(deq0, deq1);
            for (int& b : bs[a]) swap(deq0[b >> 1], deq1[b >> 1]);
            deq0.emplace_front(x);
            deq1.emplace_back(y);
        } else {
            swap(deq0, deq1);
            for (int& b : bs[a]) swap(deq0[b >> 1], deq1[b >> 1]);
        }
    };
    for (int i = 0; i < h; i++) SWAP(i);

    vector<int> to;
    for (int i = 0; i < w / 2; i++) {
        to.emplace_back(deq0.front());
        deq0.pop_front();
        to.emplace_back(deq1.front());
        deq1.pop_front();
    }
    vector<int> ans(w);
    for (int i = 0; i < w; i++) ans[to[i]] = i;
    for (int& x : ans) cout << x + 1 << '\n';
    return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 14272
final_rank: 10

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, t) for (int i = (int)(s); i < (int)(t); ++i)

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    int h, w, n;
    cin >> h >> w >> n;
    vector<pair<int, int>> ab;
    rep(i,0,n) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        ab.push_back({a, b});
    }
    sort(ab.begin(), ab.end());
    vector<int> num(w);
    iota(num.begin(), num.end(), 0);
    for (auto [a, b] : ab) {
        a %= 2*w;
        int i = (b-a+2*w) % (2*w);
        if (i >= w) i = 2*w-1-i;
        int j = (b+1+a+2*w) % (2*w);
        if (j >= w) j = 2*w-1-j;
        swap(num[i], num[j]);
    }
    vector<int> ans(w);
    rep(k,0,w) {
        int j;
        if (k % 2 == 0) j = (k+h) % (2*w);
        else j = (k-(h%(2*w))+2*w) % (2*w);
        if (j >= w) j = 2*w-1-j;
        ans[num[k]] = j;
    }
    rep(i,0,w) {
        cout << ans[i]+1 << "\n";
    }
}
accuracy: 1
time_ms: 40
memory_kb: 6096
final_rank: 1

code_snippet: #include<bits/stdc++.h> 
using namespace std;
using ll=long long int;
//using Int=__int128;
#define ALL(A) A.begin(),A.end()
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
template<typename T> constexpr int bitUP(T x,int a){return (x>>a)&1;}
//→　↓　←　↑ 
int dh[4]={0,1,0,-1}, dw[4]={1,0,-1,0};
//右上から時計回り
//int dh[8]={-1,0,1,1,1,0,-1,-1}, dw[8]={1,1,1,0,-1,-1,-1,0};
long double EPS = 1e-6;
long double PI = acos(-1);
const ll INF=(1LL<<62);
const int MAX=(1<<30);
constexpr ll MOD=1000000000+7;
//constexpr ll MOD=998244353;


inline void bin101(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
}

using Graph=vector<vector<int>>;

template<typename T >
struct edge {
	int to;
	T cost;
	edge()=default;
	edge(int to, T cost) : to(to), cost(cost) {}

};
template<typename T>
using WeightGraph=vector<vector<edge<T>>>;

//要素数n 初期値x
template<typename T>
inline vector<T> vmake(size_t n,T x){
	return vector<T>(n,x);
}

//a,b,c,x data[a][b][c] 初期値x
template<typename... Args>
auto vmake(size_t n,Args... args){
	auto v=vmake(args...);
	return vector<decltype(v)>(n,move(v));
}
struct ModInt{
    using u64=uint_fast64_t;
    u64 a;
    constexpr ModInt() :a(0){}
    constexpr ModInt(ll x) :a((x>=0)?(x%MOD):(x%MOD+MOD) ) {}

    inline constexpr ModInt operator+(const ModInt rhs)const noexcept{
        return ModInt(*this)+=rhs;
    }
    inline constexpr ModInt operator-(const ModInt rhs)const noexcept{
        return ModInt(*this)-=rhs;
    }
    inline constexpr ModInt operator*(const ModInt rhs)const noexcept{
        return ModInt(*this)*=rhs;
    }
    inline constexpr ModInt operator/(const ModInt rhs)const noexcept{
        return ModInt(*this)/=rhs;
    }
    inline constexpr ModInt operator+(const ll rhs) const noexcept{
        return ModInt(*this)+=ModInt(rhs);
    }
    inline constexpr ModInt operator-(const ll rhs)const noexcept{
        return ModInt(*this)-=ModInt(rhs);
    }
    inline constexpr ModInt operator*(const ll rhs)const noexcept{
        return ModInt(*this)*=ModInt(rhs);
    }
    inline constexpr ModInt operator/(const ll rhs)const noexcept{
        return ModInt(*this)/=ModInt(rhs);
    }

    inline constexpr ModInt &operator+=(const ModInt rhs)noexcept{
        a+=rhs.a;
        if(a>=MOD) a-=MOD;
        return *this;
    }
    inline constexpr ModInt &operator-=(const ModInt rhs)noexcept{
        if(rhs.a>a) a+=MOD;
        a-=rhs.a;
        return *this;
    }
    inline constexpr ModInt &operator*=(const ModInt rhs)noexcept{
        a=(a*rhs.a)%MOD;
        return *this;
    }
    inline constexpr ModInt &operator/=(ModInt rhs)noexcept{
        a=(a*rhs.inverse().a)%MOD;
        return *this;
    }
    inline constexpr ModInt &operator+=(const ll rhs)noexcept{
        return *this+=ModInt(rhs);
    }
    inline constexpr ModInt &operator-=(const ll rhs)noexcept{
        return *this-=ModInt(rhs);
    }
    inline constexpr ModInt &operator*=(const ll rhs)noexcept{
        return *this*=ModInt(rhs);
    }
    inline constexpr ModInt &operator/=(const ll rhs)noexcept{
        return *this/=ModInt(rhs);
    }

    inline constexpr ModInt operator=(const ll x)noexcept{
        a=(x>=0)?(x%MOD):(x%MOD+MOD);
        return *this;
    }

    inline constexpr bool operator==(const ModInt p)const noexcept{
        return a==p.a;
    }

    inline constexpr bool operator!=(const ModInt p)const noexcept{
        return a!=p.a;
    }

    inline constexpr ModInt pow(ll N) const noexcept{
        ModInt ans(1LL),p(a);
        while(N>0){
            if(bitUP(N,0)){
                ans*=p;
            }
            p*=p;
            N>>=1;
        }
        return ans;
    }
    inline constexpr ModInt inverse() const noexcept{
        return pow(MOD-2);
    }

};
inline constexpr ModInt operator+(const ll &a,const ModInt &b)noexcept{
    return ModInt(a)+=b;
}
inline constexpr ModInt operator-(const ll &a,const ModInt &b)noexcept{
    return ModInt(a)-=b;
}
inline constexpr ModInt operator*(const ll &a,const ModInt &b)noexcept{
    return ModInt(a)*=b;
}
inline constexpr ModInt operator/(const ll &a,const ModInt &b)noexcept{
    return ModInt(a)/=b;
}
//cout
inline ostream &operator<<(ostream &os,const ModInt &p) {
    return os<<p.a;
}

//cin
inline istream &operator>>(istream &is,ModInt &p) {
    ll t;
    is>>t;
    p=t;
    return is;
}

struct Binominal{
    vector<ModInt> fac,finv,inv; //fac[n]:n! finv:(n!)の逆元
    int sz;
    Binominal(int n=10) :sz(1){
        if(n<=0) n=10;
        init(n);
    }
    inline void init(int n){
        fac.resize(n+1,1);
        finv.resize(n+1,1);
        inv.resize(n+1,1);
        for(int i=sz+1;i<=n;i++){
            fac[i]=fac[i-1]*i;
            inv[i]=MOD-inv[MOD%i]*(MOD/i);
            finv[i]=finv[i-1]*inv[i];
        }
        sz=n;
    }
    //nCk(n,k<=N) をO(1)で求める
    inline ModInt com(int n,int k){
        if(n<k) return ModInt(0);
        if(n<0 || k<0) return ModInt(0);
        if(n>sz) init(n);
        return fac[n]*finv[k]*finv[n-k];
    }
    //nCk(k<=N) をO(k)　で求める 
    inline ModInt rcom(ll n,int k){
        if(n<0 || k<0 || n<k) return ModInt(0);
        if(k>sz) init(k);
        ModInt ret(1);
        for(int i=0;i<k;i++){
            ret*=n-i;
        }
        ret*=finv[k];
        return ret;
    }

    //重複組み合わせ n種類のものから重複を許してk個を選ぶ
    //〇がn個,|がk個
    inline ModInt h(int n,int k){
        return com(n+k-1,k);
    }
};

int H,W,N;
vector<int> L,R;

pair<int,int> f(int h,int w){
    int l=h;
    l-=(w-1);
    int r=h;
    r-=(W-w-1);
    l=L[(l+2*W)%(2*W)];
    r=R[(r+2*W)%(2*W)];
    return make_pair(l,r);
}

void solve(){
    cin>>H>>W>>N;
    vector<pair<int,int>> E(N);
    for(int i=0;i<N;i++) cin>>E[i].first>>E[i].second;
    L.resize(2*W);
    R.resize(2*W);

    for(int h=1;h<1+W;h+=2){
        if(h==1){
            L[h]=1;
            R[h]=W;
        }else{
            L[h]=1+h-2;
            R[h]=W+1-L[h];
        }
    }
    for(int h=1+W;h<1+2*W;h+=2){
        L[h]=R[h-W];
        R[h]=L[h-W];
    }

    sort(E.begin(),E.end());
    vector<int> A(W+1);
    for(int i=1;i<=W;i++) A[i]=i;

    for(auto e:E){
        auto a=f(e.first,e.second);
        swap(A[a.first],A[a.second]);
    }
    vector<int> ans(W+1);
    if(H%2==0){
        for(int w=1;w<=W;w+=2){
            auto a=f(H+1,w);
            ans[A[a.first]]=w;
            ans[A[a.second]]=w+1;
        }
    }else{
        ans[A[f(H,1).second]]=1;
        for(int w=2;w<=W;w+=2){
            auto a=f(H+1,w);
            ans[A[a.first]]=w;
            ans[A[a.second]]=w+1;
        }
        ans[A[f(H,W-1).first]]=W;
    }
    for(int w=1;w<=W;w++){
        cout<<ans[w]<<endl;
    }
}

int main(){
    bin101();
    int T=1;
    //cin>>T;
    while(T--) solve();
}
accuracy: 1
time_ms: 170
memory_kb: 9408
final_rank: 13

code_snippet: #include<bits/stdc++.h> 
using namespace std;
using ll=long long int;
//using Int=__int128;
#define ALL(A) A.begin(),A.end()
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
template<typename T> constexpr int bitUP(T x,int a){return (x>>a)&1;}
//→　↓　←　↑ 
int dh[4]={0,1,0,-1}, dw[4]={1,0,-1,0};
//右上から時計回り
//int dh[8]={-1,0,1,1,1,0,-1,-1}, dw[8]={1,1,1,0,-1,-1,-1,0};
long double EPS = 1e-6;
long double PI = acos(-1);
const ll INF=(1LL<<62);
const int MAX=(1<<30);
constexpr ll MOD=1000000000+7;
//constexpr ll MOD=998244353;


inline void bin101(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
}

using Graph=vector<vector<int>>;

template<typename T >
struct edge {
	int to;
	T cost;
	edge()=default;
	edge(int to, T cost) : to(to), cost(cost) {}

};
template<typename T>
using WeightGraph=vector<vector<edge<T>>>;

//要素数n 初期値x
template<typename T>
inline vector<T> vmake(size_t n,T x){
	return vector<T>(n,x);
}

//a,b,c,x data[a][b][c] 初期値x
template<typename... Args>
auto vmake(size_t n,Args... args){
	auto v=vmake(args...);
	return vector<decltype(v)>(n,move(v));
}
struct ModInt{
    using u64=uint_fast64_t;
    u64 a;
    constexpr ModInt() :a(0){}
    constexpr ModInt(ll x) :a((x>=0)?(x%MOD):(x%MOD+MOD) ) {}

    inline constexpr ModInt operator+(const ModInt rhs)const noexcept{
        return ModInt(*this)+=rhs;
    }
    inline constexpr ModInt operator-(const ModInt rhs)const noexcept{
        return ModInt(*this)-=rhs;
    }
    inline constexpr ModInt operator*(const ModInt rhs)const noexcept{
        return ModInt(*this)*=rhs;
    }
    inline constexpr ModInt operator/(const ModInt rhs)const noexcept{
        return ModInt(*this)/=rhs;
    }
    inline constexpr ModInt operator+(const ll rhs) const noexcept{
        return ModInt(*this)+=ModInt(rhs);
    }
    inline constexpr ModInt operator-(const ll rhs)const noexcept{
        return ModInt(*this)-=ModInt(rhs);
    }
    inline constexpr ModInt operator*(const ll rhs)const noexcept{
        return ModInt(*this)*=ModInt(rhs);
    }
    inline constexpr ModInt operator/(const ll rhs)const noexcept{
        return ModInt(*this)/=ModInt(rhs);
    }

    inline constexpr ModInt &operator+=(const ModInt rhs)noexcept{
        a+=rhs.a;
        if(a>=MOD) a-=MOD;
        return *this;
    }
    inline constexpr ModInt &operator-=(const ModInt rhs)noexcept{
        if(rhs.a>a) a+=MOD;
        a-=rhs.a;
        return *this;
    }
    inline constexpr ModInt &operator*=(const ModInt rhs)noexcept{
        a=(a*rhs.a)%MOD;
        return *this;
    }
    inline constexpr ModInt &operator/=(ModInt rhs)noexcept{
        a=(a*rhs.inverse().a)%MOD;
        return *this;
    }
    inline constexpr ModInt &operator+=(const ll rhs)noexcept{
        return *this+=ModInt(rhs);
    }
    inline constexpr ModInt &operator-=(const ll rhs)noexcept{
        return *this-=ModInt(rhs);
    }
    inline constexpr ModInt &operator*=(const ll rhs)noexcept{
        return *this*=ModInt(rhs);
    }
    inline constexpr ModInt &operator/=(const ll rhs)noexcept{
        return *this/=ModInt(rhs);
    }

    inline constexpr ModInt operator=(const ll x)noexcept{
        a=(x>=0)?(x%MOD):(x%MOD+MOD);
        return *this;
    }

    inline constexpr bool operator==(const ModInt p)const noexcept{
        return a==p.a;
    }

    inline constexpr bool operator!=(const ModInt p)const noexcept{
        return a!=p.a;
    }

    inline constexpr ModInt pow(ll N) const noexcept{
        ModInt ans(1LL),p(a);
        while(N>0){
            if(bitUP(N,0)){
                ans*=p;
            }
            p*=p;
            N>>=1;
        }
        return ans;
    }
    inline constexpr ModInt inverse() const noexcept{
        return pow(MOD-2);
    }

};
inline constexpr ModInt operator+(const ll &a,const ModInt &b)noexcept{
    return ModInt(a)+=b;
}
inline constexpr ModInt operator-(const ll &a,const ModInt &b)noexcept{
    return ModInt(a)-=b;
}
inline constexpr ModInt operator*(const ll &a,const ModInt &b)noexcept{
    return ModInt(a)*=b;
}
inline constexpr ModInt operator/(const ll &a,const ModInt &b)noexcept{
    return ModInt(a)/=b;
}
//cout
inline ostream &operator<<(ostream &os,const ModInt &p) {
    return os<<p.a;
}

//cin
inline istream &operator>>(istream &is,ModInt &p) {
    ll t;
    is>>t;
    p=t;
    return is;
}

struct Binominal{
    vector<ModInt> fac,finv,inv; //fac[n]:n! finv:(n!)の逆元
    int sz;
    Binominal(int n=10) :sz(1){
        if(n<=0) n=10;
        init(n);
    }
    inline void init(int n){
        fac.resize(n+1,1);
        finv.resize(n+1,1);
        inv.resize(n+1,1);
        for(int i=sz+1;i<=n;i++){
            fac[i]=fac[i-1]*i;
            inv[i]=MOD-inv[MOD%i]*(MOD/i);
            finv[i]=finv[i-1]*inv[i];
        }
        sz=n;
    }
    //nCk(n,k<=N) をO(1)で求める
    inline ModInt com(int n,int k){
        if(n<k) return ModInt(0);
        if(n<0 || k<0) return ModInt(0);
        if(n>sz) init(n);
        return fac[n]*finv[k]*finv[n-k];
    }
    //nCk(k<=N) をO(k)　で求める 
    inline ModInt rcom(ll n,int k){
        if(n<0 || k<0 || n<k) return ModInt(0);
        if(k>sz) init(k);
        ModInt ret(1);
        for(int i=0;i<k;i++){
            ret*=n-i;
        }
        ret*=finv[k];
        return ret;
    }

    //重複組み合わせ n種類のものから重複を許してk個を選ぶ
    //〇がn個,|がk個
    inline ModInt h(int n,int k){
        return com(n+k-1,k);
    }
};

int H,W,N;
vector<int> L,R;

pair<int,int> f(int h,int w){
    int l=h;
    l-=(w-1);
    int r=h;
    r-=(W-w-1);
    l=L[(l+2*W)%(2*W)];
    r=R[(r+2*W)%(2*W)];
    return make_pair(l,r);
}

void solve(){
    cin>>H>>W>>N;
    vector<pair<int,int>> E(N);
    for(int i=0;i<N;i++) cin>>E[i].first>>E[i].second;
    L.resize(2*W);
    R.resize(2*W);

    for(int h=1;h<1+W;h+=2){
        if(h==1){
            L[h]=1;
            R[h]=W;
        }else{
            L[h]=1+h-2;
            R[h]=W+1-L[h];
        }
    }
    for(int h=1+W;h<1+2*W;h+=2){
        L[h]=R[h-W];
        R[h]=L[h-W];
    }

    sort(E.begin(),E.end());
    vector<int> A(W+1);
    for(int i=1;i<=W;i++) A[i]=i;

    for(auto e:E){
        auto a=f(e.first,e.second);
        swap(A[a.first],A[a.second]);
    }
    vector<int> ans(W+1);
    if(H%2==0){
        for(int w=1;w<=W;w+=2){
            auto a=f(H+1,w);
            ans[A[a.first]]=w;
            ans[A[a.second]]=w+1;
        }
    }else{
        ans[A[f(H,0).second]]=1;
        for(int w=2;w<=W;w+=2){
            auto a=f(H+1,w);
            ans[A[a.first]]=w;
            ans[A[a.second]]=w+1;
        }
        ans[A[f(H,W-1).first]]=W;
    }
    for(int w=1;w<=W;w++){
        cout<<ans[w]<<endl;
    }
}

int main(){
    bin101();
    int T=1;
    //cin>>T;
    while(T--) solve();
}
accuracy: 0.09090909090909091
time_ms: 20
memory_kb: 4656
final_rank: 20

code_snippet: #pragma GCC optimize("Ofast")
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
#include <sstream>
#include <utility>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h,w,n; cin >> h >> w >> n;
    vector<vector<int>> v(h+1);
    for(int i=0;i<n;i++){
        int a,b; cin >> a >> b;
        v[a].push_back(b);
    }
    deque<int> dq[2];
    for(int i=1;i<=w;i++){
        if(i&1){
            dq[0].push_back(i);
        }
        else{
            dq[1].push_back(i);
        }
    }
    for(int i=1;i<=h;i++){
        if(i&1){
            swap(dq[0],dq[1]);
            for(int &j:v[i]){
                swap(dq[0][j/2],dq[1][j/2]);
            }
        }
        else{
            if(w > 2){
                dq[1].push_front(dq[0][0]);
                dq[0].pop_front();
                dq[0].push_back(dq[1].back());
                dq[1].pop_back();
                swap(dq[0],dq[1]);
            }
            for(int &j:v[i]){
                swap(dq[0][j/2],dq[1][j/2-1]);
            }
        }
    }
    vector<int> res(w+1);
    for(int i=0;i<w/2;i++){
        res[dq[0][i]] = i*2+1;
        res[dq[1][i]] = i*2+2;
    }
    for(int i=1;i<=w;i++){
        cout << res[i] << "\n";
    }
}
accuracy: 1
time_ms: 40
memory_kb: 13352
final_rank: 9

code_snippet: #pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define DEBUG
#ifdef DEBUG
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << '{';
    for(int i = 0; i < (int)v.size(); i++) {
        if(i) { os << ','; }
        os << v[i];
    }
    os << '}';
    return os;
}
void debugg() { cerr << endl; }
template <class T, class... Args>
void debugg(const T &x, const Args &... args) {
    cerr << " " << x;
    debugg(args...);
}
#define debug(...)                                                             \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]: ", debugg(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = (1<<30)-1;
const ll linf = 1LL<<61;
const int MAX = 510000;
int dy[8] = {0,1,0,-1,1,-1,-1,1};
int dx[8] = {-1,0,1,0,1,-1,1,-1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    int sz = a.size();
    for(auto itr = a.begin(); itr != a.end(); itr++){
		cout << *itr;
        sz--;
        if(sz) cout << " ";
	}
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){
	cout << a << " " << b << "\n";
}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
void mark() {cout << "#" << "\n";}
ll pcount(ll x) {return __builtin_popcountll(x);}
//#include <atcoder/all>
//using namespace atcoder;
//const int mod = 1e9 + 7;
const int mod = 998244353;

int f(int y, int x, int w){
    if((x+y) & 1){
        if(y<=x) return x-y+2;
        y-=x;
        if(y==1) return 1;
        y--;
        y %= 2*w;
        if(y == 0) return 1; 
        if(y <= w) return y;
        else return 2*w-y+1;
    }else{
        if(y<=w-1-x) return x+y;
        y-=w-1-x;
        if(y==1) return w;
        y--;
        y %= 2*w;
        if(y == 0) return w;
        if(y <= w) return w-y+1;
        else return y-w;
    }
}

int main(){
	int h,w,n; cin >> h >> w >> n;
    vpl v(n);
    rep(i,n) cin >> v[i].first >> v[i].second;
    sort(all(v));
    vl ans(w);
    vl id(w); iota(all(id),0);
    rep(i,w) ans[i] = f(h+1,i,w);
    rep(i,n){
        int y = v[i].first;
        int x = v[i].second;
        int L = f(y,x-1,w) - 1;
        int R = f(y,x,w) - 1;
        swap(id[L],id[R]);
    }
    rep(i,w) ans[id[f(h+1,i,w)-1]] = i+1;
    rep(i,w) cout << ans[i] << "\n";
}
accuracy: 1
time_ms: 90
memory_kb: 9244
final_rank: 3

code_snippet: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int H,W,N;
pair<int,int>ab[2<<17];
int f(int x,int to,int h)
{
	h%=2*W;
	if(h>=W)
	{
		return f(W-x-1,W-to-1,h-W);
	}
	if(x<to)
	{
		int rx=W-x-1;
		if(h<=rx)
		{
			return x+h;
		}
		else
		{
			h-=rx+1;
			return W-h-1;
		}
	}
	else
	{
		int rx=x;
		if(h<=rx)
		{
			return x-h;
		}
		else
		{
			h-=rx+1;
			return h;
		}
	}
}
main()
{
	cin>>H>>W>>N;
	for(int i=0;i<N;i++)
	{
		int a,b;cin>>a>>b;
		ab[i]=make_pair(a-1,b-1);
	}
	sort(ab,ab+N);
	vector<int>ps(W);
	for(int i=0;i<W;i++)ps[i]=i;
	vector<int>mv(W);
	for(int i=0;i<W;i++)mv[i]=i;
	for(int i=0;i<W;i+=2)
	{
		swap(mv[i],mv[i+1]);
	}
	for(int i=1;i+1<W;i+=2)
	{
		swap(mv[i],mv[i+1]);
	}
	int nh=H/2;
	while(nh)
	{
		if(nh&1)
		{
			vector<int>nxt(W);
			for(int i=0;i<W;i++)nxt[i]=mv[ps[i]];
			ps.swap(nxt);
		}
		nh>>=1;
		vector<int>nxt(W);
		for(int i=0;i<W;i++)nxt[i]=mv[mv[i]];
		mv.swap(nxt);
	}
	if(H%2==1)
	{
		for(int i=0;i<W;i+=2)swap(ps[i],ps[i+1]);
	}
	for(int i=0;i<N;i++)
	{
		int rh=H-ab[i].first;
		int x=ab[i].second,y=ab[i].second+1;
		int tx=f(x,y,rh);
		int ty=f(y,x,rh);
		swap(ps[tx],ps[ty]);
	}
	vector<int>ans(W);
	for(int i=0;i<W;i++)ans[ps[i]]=i;
	for(int i=0;i<W;i++)cout<<ans[i]+1<<endl;
}
accuracy: 1
time_ms: 270
memory_kb: 6900
final_rank: 14

code_snippet: // clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(false);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  int H, W, N;
  cin >> H >> W >> N;

  auto left = [&](int i, int j) {
    int s = (j + (i + 1)) / W;
    int t = (j + (i + 1) % W) % W;
    if (s % 2) {
      return W - 1 - t;
    } else {
      return t;
    }
  };
  auto right = [&](int i, int j) {
    int s = (j - i), t;
    if (s < 0) {
      s = (s + 1) / W - 1;
      t = W - 1 - abs(j - i + 1) % W;
    } else {
      s = s / W;
      t = (j - i) % W;
    }
    if (s % 2) {
      return W - 1 - t;
    } else {
      return t;
    }
  };
  vector<tuple<int, int, int, int>> A(N);
  rep(i, 0, N) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    A[i] = make_tuple(a, b, left(a, b), right(a, b));
  }
  sort(all(A));

  vi seq(W);
  if (H % 2) {
    rep(i, 0, W) {
      if (i % 2) {
        seq[i] = right(H - 1, i - 1);
      } else {
        seq[i] = left(H - 1, i);
      }
    }
  } else {
    seq[0] = left(H - 2, 0);
    rep(i, 1, W - 1) {
      if (i % 2) {
        seq[i] = left(H - 1, i);
      } else {
        seq[i] = right(H - 1, i - 1);
      }
    }
    seq[W - 1] = right(H - 2, W - 2);
  }

  vi idx(W);
  rep(i, 0, W) idx[i] = i;

  vi ans(W);
  rep(i, 0, W) ans[seq[i]] = i + 1;
  rep(i, 0, N) {
    int l, r;
    tie(ignore, ignore, l, r) = A[i];
    swap(ans[idx[l]], ans[idx[r]]);
    swap(idx[l], idx[r]);
  }
  for (int x : ans) cout << x << endl;
}
accuracy: 1
time_ms: 220
memory_kb: 13904
final_rank: 17

code_snippet: #include<bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);++i)
#define per(i,n) for(int i=(n)-1;i>=0;--i)
#define repa(i,n) for(int i=1;i<(n);++i)
#define lp(i,n) rep(i,n)
#define foreach(i,n) for(auto &i:(n))
#define all(x) (x).begin(),(x).end()
#define bit(x) (1ll << (x))
using ll = long long;
const ll MOD = 1e9+7;
const ll INF = 1e9+7;

using namespace std;

template<class t,class u>
bool chmin(t &a,u b){
	if(a>b){
		a = b;
		return true;
	}
	return false;
}



template<class t>
using vvector = vector<vector<t>>;
using pii = pair<int,int>;

vector<int> func(){
	int h;
	int w;
	int n;
	cin >> h >> w >> n;

	auto culx = [&](int y,int pos){
		int x = (y + pos * 2) % (w * 2);
		if(x<=w){
			return min(x,w-1);
		}else{
			return max(0,2*w-x-1);
		}
	};

	auto culpos_Hoged = [&](int y,int x){
		for(int i=0;i<w;++i){
			if(culx(y,i)==x){
				return i;
			}
		}
		return -1;
	};

	function<int(int,int)> culpos = (function<int(int,int)>)[&](int y,int x) -> int{
		y %= 2 * w;
		if(y>=w){
			return culpos(y-w,w-x-1);
		}
		if((y-x)%2){
			int dis = (w-y+w-x - 1) / 2;
			return dis;
		}else{
			int dis = (x-y) / 2;
			if(dis>=0)return dis;
			return w + dis;
		}
		return -1;
	};

//	for(int i=1;i<=h;++i){
//		for(int j=0;j<w;++j){
//			cout << culx(i,j) << " ";
//		}
//		cout << endl;
//	}


	vector<int> line;
	for(int i=0;i<w;i+=2){
		line.emplace_back(i+1);
	}
	for(int i=w-1;i>=0;i-=2){
		line.emplace_back(i+1);
	}

	vector<pii> amida(n);
	foreach(i,amida){
		int a;
		int b;
		cin >> a >> b;
		i = pii(a,b-1);
	}

	sort(all(amida));


	auto toout = [&](int y){
		vector<int> res(w);
		rep(i,w){
			res[line[culpos(y,i)]-1] = i+1;
		}
		return res;
	};

	auto output = [&](int y){
		foreach(i,toout(y)){
			cout << i << " ";
		}
		cout << endl;
		return;
	};

	int itr = 0;
	for(int y=1;y<=h;++y){
		while(itr<n and amida[itr].first==y){
			int a = culpos(y,amida[itr].second);
			int b = culpos(y,amida[itr].second+1);
			swap(line[a],line[b]);
			++itr;
		}
	}

	return toout(h);
}




int main(){
	vector<int> ans = func();
	foreach(i,ans){
		cout << i << endl;
	}
	return 0;
}
accuracy: 1
time_ms: 210
memory_kb: 6228
final_rank: 7

code_snippet: #include<bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);++i)
#define per(i,n) for(int i=(n)-1;i>=0;--i)
#define repa(i,n) for(int i=1;i<(n);++i)
#define lp(i,n) rep(i,n)
#define foreach(i,n) for(auto &i:(n))
#define all(x) (x).begin(),(x).end()
#define bit(x) (1ll << (x))
using ll = long long;
const ll MOD = 1e9+7;
const ll INF = 1e9+7;

using namespace std;

template<class t,class u>
bool chmin(t &a,u b){
	if(a>b){
		a = b;
		return true;
	}
	return false;
}



template<class t>
using vvector = vector<vector<t>>;
using pii = pair<int,int>;

vector<int> func(){
	int h;
	int w;
	int n;
	cin >> h >> w >> n;

	auto culx = [&](int y,int pos){
		int x = (y + pos * 2) % (w * 2);
		if(x<=w){
			return min(x,w-1);
		}else{
			return max(0,2*w-x-1);
		}
	};

	auto culpos_Hoged = [&](int y,int x){
		for(int i=0;i<w;++i){
			if(culx(y,i)==x){
				return i;
			}
		}
		return -1;
	};

	function<int(int,int)> culpos = (function<int(int,int)>)[&](int y,int x) -> int{
		y %= 2 * w;
		if(y>=w){
			return culpos(y-w,w-x-1);
		}
		if((y-x)%2){
			int dis = (w-y+w-x - 1) / 2;
			return dis;
		}else{
			int dis = (x-y) / 2;
			if(dis>=0)return dis;
			return w + dis;
		}
		return -1;
	};

//	for(int i=1;i<=h;++i){
//		for(int j=0;j<w;++j){
//			cout << culx(i,j) << " ";
//		}
//		cout << endl;
//	}


	vector<int> line;
	for(int i=0;i<w;i+=2){
		line.emplace_back(i+1);
	}
	for(int i=w-1;i>=0;i-=2){
		line.emplace_back(i+1);
	}

	vector<pii> amida(n);
	foreach(i,amida){
		int a;
		int b;
		cin >> a >> b;
		i = pii(a,b-1);
	}

	sort(all(amida));


	auto toout = [&](int y){
		vector<int> res(w);
		rep(i,w){
			res[line[culpos(y,i)]-1] = i+1;
		}
		return res;
	};

	auto output = [&](int y){
		foreach(i,toout(y)){
			cout << i << " ";
		}
		cout << endl;
		return;
	};

	int itr = 0;
	for(int y=1;y<=h;++y){
		while(itr<n and amida[itr].first==y){
			int a = culpos(y,amida[itr].second);
			int b = culpos(y,amida[itr].second+1);
			swap(line[a],line[b]);
			++itr;
		}
	}

	return toout(h);
}




int main(){
	vector<int> ans = func();
	foreach(i,ans){
		cout << i << endl;
	}
	return 0;
}
accuracy: 1
time_ms: 210
memory_kb: 6092
final_rank: 6

code_snippet: #include <bits/stdc++.h>
using namespace std;
const int LOG = 19;
int get(vector<vector<int>> &next, int y, int x){
  if (y % 2 == 1){
    return get(next, y - 1, x ^ 1);
  }
  for (int i = 0; i < LOG; i++){
    if ((y / 2) >> i & 1){
      x = next[i][x];
    }
  }
  return x;
}
int main(){
  int h, w, n;
  cin >> h >> w >> n;
  vector<pair<int, int>> s(n);
  for (int i = 0; i < n; i++){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    s[i] = make_pair(a, b);
  }
  sort(s.begin(), s.end());
  vector<vector<int>> next(LOG, vector<int>(w));
  for (int i = 0; i < w; i++){
    next[0][i] = i;
  }
  for (int i = 0; i < w / 2; i++){
    swap(next[0][i * 2], next[0][i * 2 + 1]);
  }
  for (int i = 0; i < w / 2 - 1; i++){
    swap(next[0][i * 2 + 1], next[0][i * 2 + 2]);
  }
  for (int i = 1; i < LOG; i++){
    for (int j = 0; j < w; j++){
      next[i][j] = next[i - 1][next[i - 1][j]];
    }
  }
  vector<int> p(w);
  for (int i = 0; i < w; i++){
    p[i] = i;
  }
  for (int i = 0; i < n; i++){
    int a = s[i].first;
    int b = s[i].second;
    int x = get(next, a + 1, b);
    int y = get(next, a + 1, b + 1);
    swap(p[x], p[y]);
  }
  vector<int> ans(w);
  for (int i = 0; i < w; i++){
    ans[p[get(next, h, i)]] = i;
  }
  for (int i = 0; i < w; i++){
    cout << ans[i] + 1 << endl;
  }
}
accuracy: 1
time_ms: 430
memory_kb: 20728
final_rank: 19

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=100005,INF=1e6;

vector<int> rev(vector<int> &A){
    vector<int> res(si(A));
    
    for(int i=0;i<si(A);i++){
        res[A[i]]=i;
    }
    
    return res;
}

vector<int> mul(vector<int> &A,vector<int> &B){
    vector<int> res=A;
    
    for(int i=0;i<si(A);i++){
        res[i]=B[res[i]];
    }
    
    return res;
}//A→Bの順で写像を適用

vector<int> pow(vector<int> &A,ll n){
    vector<int> res(si(A));
    iota(all(res),0);
    
    while(n>0){
        if(n&1) res=mul(res,A);
        A=mul(A,A);
        n/=2;
    }
    
    return res;
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int H,W,N;cin>>H>>W>>N;
    vector<pair<int,int>> S(N);
    for(int i=0;i<N;i++){
        cin>>S[i].fi>>S[i].se;
        S[i].fi--;S[i].se--;
    }
    sort(all(S));
    reverse(all(S));
    
    vector<int> ans(W);
    iota(all(ans),0);
    
    vector<int> A,B,C;
    A=ans;B=ans;
    for(int i=0;i+1<W;i+=2) swap(A[i],A[i+1]);
    for(int i=1;i+1<W;i+=2) swap(B[i],B[i+1]);
    
    C=mul(A,B);
    C=pow(C,H/2);
    
    ans=mul(ans,C);
    if(H&1) ans=mul(ans,A);
    
    for(int i=0;i<N;i++){
        int h=S[i].fi,w=S[i].se,a=-1,b=-1;
        
        if(h>w){
            int nh=h-w;
            nh--;
            nh%=2*W;
            if(nh<W) a=nh;
            else a=W-1-(nh-W);
        }else{
            a=w-h;
        }
        
        w=W-1-(w+1);
        swap(a,b);
        
        if(h>w){
            int nh=h-w;
            nh--;
            nh%=2*W;
            if(nh<W) a=nh;
            else a=W-1-(nh-W);
        }else{
            a=w-h;
        }
        
        a=W-1-a;
        
        swap(a,b);
        
        swap(ans[a],ans[b]);
    }
    
    for(int i=0;i<W;i++){
        cout<<ans[i]+1<<"\n";
    }
}
accuracy: 1
time_ms: 50
memory_kb: 9200
final_rank: 2

code_snippet: #include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> H >> W >> N;
	vector<pair<int, int>>v(N);
	for (auto &i : v) {
		cin >> i.first >> i.second;
		i.first--, i.second--;
	}
	vector<int>box(W);
	for (int i = 1; i < W; i++)box[i] = i;
	sort(v.begin(), v.end());
	for (auto i : v) {
		int md = i.first % (1 * W);
		int l = -1, r = -1;
		if (md == i.second)l = 0;
		else if (md > i.second)l = md - i.second - 1;
		else l = i.second - md;
		i.second = W - 2 - i.second;
		if (md == i.second)r = 0;
		else if (md > i.second)r = md - i.second - 1;
		else r = i.second - md;
		i.second = W - 2 - i.second;
		r = W - 1 - r;
		if (i.first % (2 * W) >= W) {
			r = W -1- r, l = W - 1-l;
		}
	//	cout << l << " " << r << endl;
		swap(box[l], box[r]);
	}
	vector<int>ans(W);
	for (int i = 0; i < W; i++) {
		
		int p = i;
		int md = H % (2 * W);
		if (i & 1) {
			int minus = min(md, i);
			md -= minus;
			p -= minus;
			md--;
			if (md >= 0) {
				minus = min((int)W - 1, md);
				md -= minus;
				p += minus;
				md--;
			}
			if (md >= 0) {
				minus = min(p, md);
				md -= minus;
				p -= minus;
				md--;
			}
		}
		else {
			int minus = min(md, ((int)W - 1) - p);
			md -= minus;
			p += minus;
			md--;
			if (md >= 0) {
				minus = min(p, md);
				md -= minus;
				p -= minus;
				md--;
			}
			if (md >= 0) {
				minus = min((int)(W - 1), md);
				md -= minus;
				p += minus;
				md--;
			}
		}
		ans[p] = box[i];
		
	}
	vector<int>ret(W);
	for (int i = 0; i < W; i++) {
		ret[ans[i]] = i + 1;
	}
	for (auto i : ret)cout << i << endl;
}
accuracy: 1
time_ms: 200
memory_kb: 6652
final_rank: 8