---
# System prepended metadata

title: 13279 - Rearrange
tags: [loop]

---

# 13279 - Rearrange
>author: Utin
###### tags: `loop`

---

## Brief
See the code below

## Solution 0

```c=
#include<stdio.h>

int s[1000];

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    s[0] = 1;
    for(int i=1; i<n; i++) {
        s[i] = s[i-1] + 1;
    }
    for(int t=0; t<m; t++) {
        int t1,t2, k = 0;
        scanf("%d %d", &t1, &t2);
        for(int i=0; i<n; i++) {
            if(s[i] == t1) {
                s[i] = t2;
                k ++;
            }
            else if(s[i] == t2) {
                s[i] = t1;
                k ++;
            }
            if(k == 2) break;
        }
    }
    for(int i=0; i<n; i++) {
        printf("%d", s[i]);
        if(i<n-1) {
            printf(" ");
        }
    }
    printf("\n");
}
// By Utin
```

## Reference