#include <fstream>
#include <iostream>
#include <vector>
#include <bitset>
#include <string.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <time.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <cassert>

using namespace std;

const char infile[] = "input.in";
const char outfile[] = "output.out";

ifstream fin(infile);
ofstream fout(outfile);

const int MAXN = 100005;
const int oo = 0x3f3f3f3f;

typedef vector<int> Graph[MAXN];
typedef vector<int> :: iterator It;

const inline int min(const int &a, const int &b) { if( a > b ) return b;   return a; }
const inline int max(const int &a, const int &b) { if( a < b ) return b;   return a; }
const inline void Get_min(int &a, const int b)    { if( a > b ) a = b; }
const inline void Get_max(int &a, const int b)    { if( a < b ) a = b; }

struct Treap {
    Treap *left, *right;
    int key, subTree, priority;
    Treap(Treap *_left, Treap *_right, int _key, int _priority, int _subTree = 1) {
        left = _left;
        right = _right;
        key = _key;
        priority = _priority;
        subTree = _subTree;
    }
} *Root, *NIL;

inline void updateSubTree(Treap *& Node) {
    if(Node == NIL) {
        Node->subTree = 0;
        return;
    }
    Node->subTree = 1 + Node->left->subTree + Node->right->subTree;
}

inline void rotateLeft(Treap *& Node) {
    Treap *aux = Node->left;
    Node->left = aux->right;
    aux->right = Node;

    Node = aux;

    updateSubTree(Node->right);
    updateSubTree(Node);
}

inline void rotateRight(Treap *& Node) {
    Treap *aux = Node->right;
    Node->right = aux->left;
    aux->left = Node;

    Node = aux;


    updateSubTree(Node->left);
    updateSubTree(Node);
}

inline void Balance(Treap *& Node) {
    if(Node->left->priority > Node->priority)
        rotateLeft(Node);
    if(Node->right->priority > Node->priority)
        rotateRight(Node);
}

inline void Insert(Treap *& Node, int key, int pos, int priority) {
    if(Node == NIL) {
        Node = new Treap(NIL, NIL, key, priority, 1);
        return;
    }
    if(pos <= Node->left->subTree + 1)
        Insert(Node->left, key, pos, priority);
    else Insert(Node->right, key, pos - Node->left->subTree - 1, priority);
    Balance(Node);
    updateSubTree(Node);
}

inline void Erase(Treap *& Node, int pos) {
    if(Node == NIL)
        return;
    if(Node->left->subTree + 1 == pos) {
        if(Node->left == NIL && Node->right == NIL) {
            delete Node;
            Node = NIL;
            return;
        }
        else {
            if(Node->left->priority > Node->right->priority) {
                rotateLeft(Node);
                Erase(Node->right, pos - Node->left->subTree - 1);
            }
            else {
                rotateRight(Node);
                Erase(Node->left, pos);
            }
        }
    }
    else if(Node->left->subTree + 1 > pos)
        Erase(Node->left, pos);
    else Erase(Node->right, pos - Node->left->subTree - 1);

    updateSubTree(Node);
}

inline int KthElement(Treap *& Node, int k) {
    if(Node == NIL)
        return 0;
    if(Node->left->subTree + 1 == k)
        return Node->key;
    else
        if(Node->left->subTree + 1 > k)
            return KthElement(Node->left, k);
        else
            return KthElement(Node->right, k - Node->left->subTree - 1);
}

inline void printTreap( Treap *& Node ) {
    if(Node == NIL)
        return;
    printTreap(Node->left);
    printTreap(Node->right);
}

int main() {
    cin.sync_with_stdio(false);
    #ifndef ONLINE_JUDGE
    freopen(infile, "r", stdin);
    freopen(outfile, "w", stdout);
    #endif

    srand(time(NULL));
    NIL = new Treap(0, 0, 0, 0, 0);
    Root = NIL;
    NIL->left = NIL->right = NIL;

    int N, M;
    scanf("%d%d", &N, &M);
    for(int i = 1 ; i <= N ; ++ i)
        Insert(Root, i, i, rand() + 1);
    for(int t = 1 ; t <= M ; ++ t) {
        char op; int x;
        scanf(" %c %d", &op, &x);
        if(op == 'D')    Erase(Root, x);
        else   printf("%d\n", KthElement(Root, x));
    }
    fin.close();
    fout.close();
    return 0;
}