#include <iostream>
using namespace std;
struct Node{
int data;
Node* pNext;
};
void insertOrderedList(Node* &pHead, int x) {
if(pHead == nullptr || pHead->data > x) {
Node* tmp = new Node;
tmp->data = x;
tmp->pNext = pHead;
pHead = tmp;
return;
}
Node* cur = pHead;
while(cur->pNext!=nullptr) {
if(cur->pNext->data > x) {
Node* tmp = new Node;
tmp->data = x;
tmp->pNext = cur->pNext;
cur->pNext = tmp;
return;
}
cur = cur->pNext;
}
Node* tmp = new Node;
tmp->data = x;
tmp->pNext = cur->pNext;
cur->pNext = tmp;
}
int main() {}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKc3RydWN0IE5vZGV7CiAgICBpbnQgZGF0YTsKICAgIE5vZGUqIHBOZXh0Owp9OwoKdm9pZCBpbnNlcnRPcmRlcmVkTGlzdChOb2RlKiAmcEhlYWQsIGludCB4KSB7CiAgICBpZihwSGVhZCA9PSBudWxscHRyIHx8IHBIZWFkLT5kYXRhID4geCkgewogICAgICAgIE5vZGUqIHRtcCA9IG5ldyBOb2RlOwogICAgICAgIHRtcC0+ZGF0YSA9IHg7CiAgICAgICAgdG1wLT5wTmV4dCA9IHBIZWFkOwogICAgICAgIHBIZWFkID0gdG1wOwogICAgICAgIHJldHVybjsKICAgIH0KCiAgICBOb2RlKiBjdXIgPSBwSGVhZDsKICAgIHdoaWxlKGN1ci0+cE5leHQhPW51bGxwdHIpIHsKICAgICAgICBpZihjdXItPnBOZXh0LT5kYXRhID4geCkgewogICAgICAgICAgICBOb2RlKiB0bXAgPSBuZXcgTm9kZTsKICAgICAgICAgICAgdG1wLT5kYXRhID0geDsKICAgICAgICAgICAgdG1wLT5wTmV4dCA9IGN1ci0+cE5leHQ7CiAgICAgICAgICAgIGN1ci0+cE5leHQgPSB0bXA7CiAgICAgICAgICAgIHJldHVybjsKICAgICAgICB9CiAgICAgICAgY3VyID0gY3VyLT5wTmV4dDsKICAgIH0KCiAgICBOb2RlKiB0bXAgPSBuZXcgTm9kZTsKICAgIHRtcC0+ZGF0YSA9IHg7CiAgICB0bXAtPnBOZXh0ID0gY3VyLT5wTmV4dDsKICAgIGN1ci0+cE5leHQgPSB0bXA7Cn0KCmludCBtYWluKCkge30=