jiahuimbzuai/CoQuIR huggingface dataset:
//  [python]
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

A,B = inputIL()

if A==B:
  print("Draw")
elif A==1:
  print("Alice")
elif B==1:
  print("Bob")
elif A>B:
  print("Alice")
else:
  print("Bob")
//  [python]
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from fractions import gcd

def readln():
    _res = list(map(int,str(input()).split(' ')))
    return _res

def strong(x,y):
    if y == 1 : return False
    return (x == 1) or (x > y)

a = readln()
if a[0] == a[1]:
    print("Draw")
elif strong(a[0],a[1]):
    print("Alice")
else:
    print("Bob")
//  [python]
a,b=map(int,input().split());print('Draw'if a==b else'Alice'if b!=1 and(a==1 or a>b)else'Bob')
//  [java]
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		
		if(a==1 && b!=1)System.out.println("Alice");
		else if(a==1 && b==1)System.out.println("Draw");
		else if(a!=1 && b==1)System.out.println("Bob");
		else if(a<b)System.out.println("Bob");
		else if(a>b)System.out.println("Alice");
		else System.out.println("Draw");
	}
}
//  [java]
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		int value1 = scan.nextInt();
		int value2 = scan.nextInt();
		
		if (value1 == value2) {
			System.out.println("Draw");
		} else {
			if (value1 == 1) {
				System.out.println("Alice");
			} else if (value2 == 1) {
				System.out.println("Bob");
			} else {
				if (value1 > value2)
					System.out.println("Alice");
				else
					System.out.println("Bob");
			}
		}
		
	}
	
	
}
//  [java]
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a == b) {
            System.out.println("Draw");
        } else if (a == 1) {
            System.out.println("Alice");
        } else if (b == 1) {
            System.out.println("Bob");
        } else if (a > b) {
            System.out.println("Alice");
        } else {
            System.out.println("Bob");
        }
    }
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;

int main(){
	int a,b;
	cin>>a>>b;
	if(a==1 and b!=1){
		cout<<"Alice"<<endl;
	}else if(b==1 and a!=1){
		cout<<"Bob"<<endl;
	}else{
		if(a==b){
			cout<<"Draw"<<endl;
		}else if(a>b){
			cout<<"Alice"<<endl;
		}else{
			cout<<"Bob"<<endl;
		}
	}
}
//  [cpp]
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string a,b; cin >> a >> b;

    int A = stoi(a);
    int B = stoi(b);

    if(A == B) { cout << "Draw" << endl; }
    else if((A > B && B != 1) || A == 1) { cout << "Alice" << endl; }
    else { cout << "Bob" << endl; }
    return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int a,b;cin>>a>>b;
  if(a==1)a=14;
  if(b==1)b=14;
  string ans="Draw";
  if(a>b)ans="Alice";
  else if(a<b)ans="Bob";
  cout(ans);
  
  return 0;
}
//  [c]
#include <stdio.h>
int main()
{
    int a,b;
    scanf("%d %d", &a, &b);

    if(a==b)
    {
        printf("Draw");
    }
    else if(a==1)
    {
        printf("Alice");
    }
    else if(b==1)
    {
        printf("Bob");
    }
    else if(a>b)
    {
        printf("Alice");
    }
    else{
        printf("Bob");
    }
    return 0;
}
//  [c]
#include <stdio.h>

int main(void){
  int A,B;
  scanf("%d %d",&A, &B);
  if (A == B){
    printf("Draw");
  } else if (A == 1 && 1 < B < 13 || A !=1 && B !=1 && A-B>0){
    printf("Alice");
  } else if (B == 1 && 1 < A < 13 || B !=1 && A !=1 && B-A>0){
    printf("Bob");
  }else {
    printf("Invalid!");
  }
             return 0;
             }
//  [c]
#include<stdio.h>

int main(){
    int a,b;
    scanf("%d%d",&a,&b);

    if(a==b){
        printf("Draw\n");
    }else if(a==1&&b==13){
        printf("Alice\n");
    }else if(a==13&&b==1){
        printf("Bob\n");
    }else if(a>b){
        printf("Alice\n");
    }else{
        printf("Bob\n");
    }
    return 0;
}
//  [javascript]
function Main(input) {
  var ab = input.split(" ");
  ab[0] = parseInt(ab[0]);
  ab[0] = parseInt(ab[0]);
  if(ab[0]==1){
    ab[0]=14;
  }
  if(ab[1]==1){
    ab[1]=14;
  }
  if (ab[0] > ab[1]) {
    process.stdout.write("Alice");
  } else if (ab[0] < ab[1]) {
    process.stdout.write("Bob");
  } else {
    process.stdout.write("Draw");
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
'use strict';

const input = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
const hands = input[0].split(' ').map(Number)

const A = hands[0] == 1 ? 14 : hands[0];
const B = hands[1] == 1 ? 14 : hands[1];

console.log(A == B ? 'Draw' : A > B ? 'Alice' : 'Bob');
//  [javascript]
function main(input) {
  const args = input.split(' ').map(n => parseInt(n, 10));
  const A = args[0];
  const B = args[1];
  
  const cards = {1: 2, 2: 3, 3: 4, 4: 5, 5: 6, 6: 7, 7: 8, 8: 9, 9: 10, 10: 11, 11: 12, 12: 13, 13: 14, 1: 15}
  
  if (cards[A] > cards[B]) {
    console.log('Alice');
  } else if (cards[A] === cards[B]) {
    console.log('Draw');
  } else {
    console.log('Bob');
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [go]
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	if a == b {
		fmt.Println("Draw")
		return
	}
	if a == 1 {
		fmt.Println("Alice")
		return
	}
	if b == 1 {
		fmt.Println("Bob")
		return
	}
	if a > b {
		fmt.Println("Alice")
	} else {
		fmt.Println("Bob")
	}
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	a, b := intScanner(), intScanner()
	if a == b {
		fmt.Println("Draw")
	} else if a == 1 {
		fmt.Println("Alice")
	} else if b == 1 {
		fmt.Println("Bob")
	} else if a > b {
		fmt.Println("Alice")
	} else {
		fmt.Println("Bob")
	}
}
//  [go]
package main

import (
  "fmt"
)

func main() {
  var a, b int
  
  fmt.Scanf("%d %d", &a, &b)
  
  ans := "Draw"
  if a > b {
    if b == 1 {
      ans = "Bob"
    }else{
      ans = "Alice"
    }
  }
  if a < b {
    if a == 1 {
      ans = "Alice"
    }else{
      ans = "Bob"
    }
  }
  fmt.Printf("%s", ans)
}
//  [ruby]
a,b = gets.split.map(&:to_i)
a = 14 if a == 1
b = 14 if b == 1
if a == b
  puts "Draw"
elsif a > b
  puts "Alice"
else
  puts "Bob"
end
//  [ruby]
a, b = gets().chomp.split("\s").map{|x| x.to_i}

a = a == 1 ? 14 : a
b = b == 1 ? 14 : b

if a > b
  puts 'Alice'
elsif a == b
  puts 'Draw'
else
  puts 'Bob'
end
//  [ruby]
a,b = gets.chomp.split(' ').map(&:to_i)
if a == b
  puts "Draw"
elsif a == 1
  puts "Alice"
elsif b == 1
  puts "Bob"
elsif a < b
  puts "Bob"
else
  puts "Alice"
end
//  [rust]
fn getline() -> String {
    let mut __ret = String::new();
    std::io::stdin().read_line(&mut __ret).ok();
    return __ret;
}

fn solve(a: i32, b: i32) -> String {
    if a == 1 && b == 1 {
        return "Draw".to_string();
    }
    if a == 1 && b != 1 {
        return "Alice".to_string();
    }
    if a != 1 && b == 1 {
        return "Bob".to_string();
    }
    if a > b {
        return "Alice".to_string();
    }
    if a < b {
        return "Bob".to_string();
    }

    return "Draw".to_string();
}

fn main() {
    let s = getline();
    let vec: Vec<i32> = s.trim().split(' ').map(|s| s.parse().unwrap()).collect();
    let a = vec[0];
    let b = vec[1];

    let ans = solve(a, b);
    println!("{}", ans);
}
//  [rust]
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        a: String,
        b: String
    };
    let arr = [
        "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "1",
    ];
    let ai = arr.iter().position(|&num| num == &a).unwrap();
    let bi = arr.iter().position(|&num| num == &b).unwrap();
    println!(
        "{}",
        if ai > bi {
            "Alice"
        } else if ai < bi {
            "Bob"
        } else {
            "Draw"
        }
    );
}
//  [rust]
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        a: usize,
        b: usize,
    }

    if a==1 {
        if b==1 {
            println!("Draw");
        } else {
            println!("Alice");
        }
    } else {
        if b==1 {
            println!("Bob");
        } else {
            if a>b {
                println!("Alice");
            } else if a==b {
                println!("Draw");
            } else {
                println!("Bob");
            }
        }
    }

}
//  [swift]
import Foundation

extension String {
    var argi: [Int] { return self.characters.split(" ").map { Int(String($0))! } }
}

let arr = readLine()!.argi

let a: Int = arr[0]
let b: Int = arr[1]

var res: String = ""

if a == b {
    res = "Draw"
}
else {
    if a == 1 || a > b && b != 1 {
        res = "Alice"
    }
    else {
        res = "Bob"
    }
}

print(res)
//  [typescript]
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [A, B] = input[0].map(Number);

  if (A === B) {
    return "Draw";
  } else if ((A > B && B !== 1) || A === 1) {
    return "Alice";
  } else {
    return "Bob";
  }
};

console.log(main(read()));
//  [typescript]
import * as fs from 'fs';

const [a, b]: number[] = fs.readFileSync('/dev/stdin', 'utf8').trim().split(' ').map(Number);


function main(): string {
    if (a === b) return 'Draw';
    if (a === 1) return 'Alice';
    if (b === 1) return 'Bob';
    if (a > b) {
        return 'Alice';
    } else {
        return 'Bob';
    }
}

console.log(main());
//  [python]
n, m = map(int, input().split())
graph = {i: [] for i in range(1, n + 1)}
for _ in range(m):
    u, v = map(int, input().split())
    graph[u].append(v)
    graph[v].append(u)

import queue
voi = [100] * (n + 1)
tf = [False] * (n + 1)
def bfs(v):
    q = queue.Queue()
    q.put(v)
    tf[v] = True
    voi[v] = 0
    while not q.empty():
        now = q.get()
        for nex in graph[now]:
            if tf[nex]:
                continue
            q.put(nex)
            voi[nex] = voi[now] + 1
            tf[nex] = True

bfs(1)
if voi[n] <= 2:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
//  [python]
import queue
N, M = map(int, input().split())
G = [[] for _ in range(N)]

for i in range(M):
    a, b = map(lambda n: int(n) - 1, input().split())
    G[a].append(b)
    G[b].append(a)

def dfs(Graph, N, start):
    q = queue.Queue()
    dist = [-1] * N
    dist[start] = 0
    q.put(start)

    while not q.empty():
        v = q.get()
        if dist[v] >1:
            continue
        for u in G[v]:
            if dist[u] != -1:
                continue
            dist[u] = dist[v] + 1
            q.put(u)

    return dist
if dfs(G, N, 0)[-1] > 2 or dfs(G, N, 0)[-1] == -1:
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')
//  [python]
import queue
n,m = map(int,input().split())

adj = [[] for i in range(n)]
dist = [-1]*n
for i in range(m):
    a,b = map(int,input().split())
    adj[a-1].append(b-1)
    adj[b-1].append(a-1)
    
q = queue.Queue()
dist[0] = 0
q.put(0)

while not q.empty():
    x = q.get()
    
    for f in adj[x]:
        if dist[f] != -1:
            continue
        
        dist[f] = dist[x] + 1
        q.put(f)
     
if dist[n-1] == 2:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
//  [java]
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		int a, b;
		Map<Integer, HashSet<Integer>> mp = new HashMap<>();
		for (int i = 0; i < m; i++) {
			a = in.nextInt();
			b = in.nextInt();
			HashSet<Integer> s1 = null, s2 = null;
			if (mp.get(a) != null) {
				s1 = mp.get(a);
			}
			if (mp.get(b) != null) {
				s2 = mp.get(b);
			}
			if (mp.get(a) == null) {
				s1 = new HashSet<Integer>();
			}
			if (mp.get(b) == null) {
				s2 = new HashSet<Integer>();
			}
			s1.add(b);
			s2.add(a);
			mp.put(a, s1);
			mp.put(b, s2);
		}
		for (Integer x : mp.get(1)) {
			if (mp.get(x).contains(n)) {
				System.out.println("POSSIBLE");
				System.exit(0);
			}
		}
		System.out.println("IMPOSSIBLE");

		in.close();
	}
}
//  [java]

import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			HashMap<Integer, HashSet<Integer>> map = new HashMap<Integer, HashSet<Integer>>(n);

			for (int i = 0; i < m; i++) {
				int a = sc.nextInt();
				int b = sc.nextInt();
				if (map.keySet().contains(a)) {
					map.get(a).add(b);
				} else {
					HashSet<Integer> tmp = new HashSet<Integer>();
					tmp.add(b);
					map.put(a, tmp);
				}
				if (map.keySet().contains(b)) {
					map.get(b).add(a);
				} else {
					HashSet<Integer> tmp = new HashSet<Integer>();
					tmp.add(a);
					map.put(b, tmp);
				}
			}

			for (int i : map.get(1)) {
				// 1から移動可能な島を探索
				for (int j : map.get(i)) {
					if (j == n) {
						System.out.println("POSSIBLE");
						return;
					}
				}
			}
			System.out.println("IMPOSSIBLE");
		}
	}
}
//  [java]
import java.util.*;
public class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
  String n=sc.next();
  int m=sc.nextInt();
  Graph g=new Graph();
  for(int i=0;i<m;i++){
  g.add(sc.next(),sc.next());
  }
  System.out.println(g.isConnect("1",n)?"POSSIBLE":"IMPOSSIBLE");
}

}
class Graph {
	Map<String, ArrayList<String>> edge ;
	Map<String, Integer> vertex ;
	public Graph() {
		edge = new HashMap<String, ArrayList<String>>();
		vertex=new HashMap<String,Integer>();
	}
	public void add(String a, String b) {
		if (edge.containsKey(a)) {
			edge.get(a).add(b);
			vertex.put(a,vertex.get(a)+1);
		} else {
			ArrayList<String>cont=new ArrayList<>();
			cont.add(b);
			edge.put(a, cont);
			vertex.put(a,1);
		}
		if (edge.containsKey(b)) {
			edge.get(b).add(a);
			vertex.put(b,vertex.get(b)+1);
		} else {
			ArrayList<String>cont=new ArrayList<>();
			cont.add(a);
			edge.put(b, cont);
			vertex.put(b,1);
		}
	}
	public boolean isConnect(String a,String b) {
		if(!vertex.containsKey(a)||!vertex.containsKey(b))return false;
		Map<String,Boolean>check=new HashMap<String,Boolean>();
		ArrayList<String>queue=new ArrayList<>();
		check.put(a,false);
        
      ArrayList<String>cont=new ArrayList<>(edge.get(a));
      for(int i=0;i<cont.size();i++)if(!check.containsKey(cont.get(i))) {
					queue.add(cont.get(i));
					check.put(cont.get(i),false);
				}
      
      for(int i=0;i<queue.size();i++){
      	ArrayList<String>cont2=new ArrayList<>(edge.get(queue.get(i)));
        for(int j=0;j<cont2.size();j++)
        	check.put(cont2.get(j),false);
      }
		return check.containsKey(b);
	}
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;

int main(void)
{
    int N,M;
    cin >> N >> M;
    int a[M];
    int b[M];
    int t1[M];
    int t2[M];
    int tmp1,tmp2;
    int count = 0;
    int count2 = 0;
    int count3 = 0;

    for( int i = 0; i < M; i++){
        cin >> tmp1 >> tmp2;
        if(tmp1 == 1 || tmp2 == N){
            a[count] = tmp1;
            b[count] = tmp2;
            count++;
        }
    }
    sort(a, a+count);
    sort(b, b+count);
    //puts("");
    for( int i = 0; i < count ; i++){
        //printf("%d %d\n",a[i],b[i]);
        if( a[i] == 1 && (count3 == 0 || t1[count3-1] != a[i])){
            t1[count3] = b[i];
            count3++;
        }
        if( b[i] == N && (count2 == 0 || t2[count2-1] != a[i])){
            t2[count2] = a[i];
            count2++;
        }
    }
    //puts("");

    if( count2 > count3){
        for( int i = 0; i < count3; i++){
            for( int j = 0; j < count2; j++){
                if( t1[i] > t2[j+count2/2]){
                    j += count2/2;
                }
                //printf("%d %d\n",t1[i],t2[j]);
                if( t1[i] == t2[j] ){
                    printf("POSSIBLE");
                    return 0;
                }
                if( t1[i] < t2[j] ){
                    break;
                }
            }
        }
    }else{
        for( int j = 0; j < count2; j++){
            for( int i = 0; i < count3; i++){
                if( t1[i+count2/2] < t2[j]){
                    i += count2/2;
                }
                //printf("i = %d, j = %d\n", i, j);
                //printf("%d %d\n",t2[j],t1[i]);
                if( t1[i] == t2[j] ){
                    printf("POSSIBLE");
                    return 0;
                }
                if( t2[j] < t1[i] ){
                    //printf("break!\n");
                    break;
                }
            }
        }
    }
    printf("IMPOSSIBLE");
    
    return 0;
}
//  [cpp]
#include<bits/stdc++.h>
//#define int long long
using namespace std;

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

  vector<int> a1;
  for (int i = 0; i < m; i++) {
    if (a[i] == 1) {
      a1.push_back(b[i]);
    }
  }
  vector<int> a2;
  for (int i = 0; i < m; i++) {
    if (b[i] == n) {
      a2.push_back(a[i]);
    }
  }

  sort(a1.begin(), a1.end());
  sort(a2.begin(), a2.end());

  
  while (1) {
    if (a1.size() == 0 || a2.size() == 0) {
      cout << "IMPOSSIBLE" << endl;
      break;
    }
    
    if (a1[0] == a2[0]) {
      cout << "POSSIBLE" << endl;
      break;
    }
    
    if (a1[0] > a2[0]) {
      a2.erase(a2.begin());
    } else {
      a1.erase(a1.begin());
    }
  }
  return 0;
}
//  [cpp]
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>
//#include <bits/stdc++.h>

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

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

using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=2147483647;
const ll LLMAX=9223372036854775807;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N,M;
    cin>>N>>M;
    vll a(M),b(M);
    vvll next(N);
    for(ll i=0;i<M;i++){
        cin>>a[i]>>b[i];
        a[i]--;b[i]--;
        next[a[i]].push_back(b[i]);
        next[b[i]].push_back(a[i]);
    }
    
    vll open;
    open.push_back(0);
    vll done(N,-1);
    done[0]=0;
    while(open.size()>0){
        ll node=open[0];
        open.erase(open.begin());
        for(ll i=0;i<next[node].size();i++){
            if(done[next[node][i]]==-1){
                done[next[node][i]]=done[node]+1;
                if(done[node]==0)open.push_back(next[node][i]);
            }
        }
    }
    if(done[N-1]!=-1)printf("POSSIBLE\n");
    else printf("IMPOSSIBLE\n");
    
    return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#define MAX_NUM 200000
#define BIRTHDAY 1009

typedef struct hash{
	int num;
	struct hash *next;
}hash;

void append(hash**, int);
void search(hash**, int);
void clean(hash**);
void possible();

int a_list[MAX_NUM] = {0};
int a_index = 0;
hash *hash_list[BIRTHDAY] = {NULL};

int main(void){
	int N, M;
	int a, b;
	int i;
	hash *p;

	scanf("%d %d", &N, &M);
	for(i = 0; i < M; i++){
		scanf("%d %d", &a, &b);
		if(a == 1){
			append(hash_list, b);
		}
		if(b == N){
			a_list[a_index++] = a;
		}
	}

	for(i=0; i<a_index; i++){
		search(hash_list, a_list[i]);
	}

	clean(hash_list);
	printf("IMPOSSIBLE");
	return 0;
}

void append(hash **list, int num){
	hash *p, *tmp;
	hash *item;
	tmp = NULL;

	for(p = list[num%BIRTHDAY]; p != NULL && p->num < num; p = p->next)
		tmp = p;

	item = (hash*)malloc(sizeof(hash));
	item->num = num;
	item->next = p;
	if(tmp == NULL)
		list[num%BIRTHDAY] = item;
	else
		tmp->next = item;
}

void search(hash **list, int num){
	hash *p;
	for(p = list[num%BIRTHDAY]; p != NULL && p->num <= num; p = p->next){
		if(p->num == num)
			possible();
	}
}

void possible(){
	clean(hash_list);
	printf("POSSIBLE");
	exit(0);
}

void clean(hash **list){
	int i;
	hash *p, *tmp;
	for(i = 0; i < BIRTHDAY; i++){
		for(p = list[i]; p != NULL; p = p->next){
			tmp = p;
			free(tmp);
		}
	}
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#define MAX_NUM 200000
#define BIRTHDAY 1009

typedef struct hash{
	int num;
	struct hash *next;
}hash;

void append(hash**, int);
void search(hash**, int);
void clean(hash**);
void possible();

int a_list[MAX_NUM] = {0};
int a_index = 0;
hash *hash_list[BIRTHDAY] = {NULL};

int main(void){
	int N, M;
	int a, b;
	int i;
	hash *p;

	scanf("%d %d", &N, &M);
	for(i = 0; i < M; i++){
		scanf("%d %d", &a, &b);
		if(a == 1){
			append(hash_list, b);
		}
		if(b == N){
			a_list[a_index++] = a;
		}
	}

	for(i=0; i<a_index; i++){
		search(hash_list, a_list[i]);
	}

	clean(hash_list);
	printf("IMPOSSIBLE");
	return 0;
}

void append(hash **list, int num){
	hash *p, *tmp;
	hash *item;
	tmp = NULL;

	for(p = list[num%BIRTHDAY]; p != NULL && p->num < num; p = p->next)
		tmp = p;

	item = (hash*)malloc(sizeof(hash));
	item->num = num;
	item->next = p;
	if(tmp == NULL)
		list[num%BIRTHDAY] = item;
	else
		tmp->next = item;
}

void search(hash **list, int num){
	hash *p;
	for(p = list[num%BIRTHDAY]; p != NULL && p->num <= num; p = p->next){
		if(p->num == num)
			possible();
	}
}

void possible(){
	clean(hash_list);
	printf("POSSIBLE");
	exit(0);
}

void clean(hash **list){
	int i;
	hash *p, *tmp;
	tmp = NULL;
	for(i = 0; i < BIRTHDAY; i++){
		for(p = list[i]; p != NULL; p = p->next){
			free(tmp);
			tmp = p;
		}
	}
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#define MAX_NUM 200000
#define BIRTHDAY 1009

typedef struct hash{
	int num;
	struct hash *next;
}hash;

void append(hash**, int);
void search(hash**, int);
void possible();

int a_list[MAX_NUM] = {0};
int a_index = 0;
hash *hash_list[BIRTHDAY] = {NULL};

int main(void){
	int N, M;
	int a, b;
	int i;
	hash *p;

	scanf("%d %d", &N, &M);
	for(i = 0; i < M; i++){
		scanf("%d %d", &a, &b);
		if(a == 1){
			append(hash_list, b);
		}
		if(b == N){
			a_list[a_index++] = a;
		}
	}

	for(i=0; i<a_index; i++){
		search(hash_list, a_list[i]);
	}

	printf("IMPOSSIBLE");
	return 0;
}

void append(hash **list, int num){
	hash *p, *tmp;
	hash *item;
	tmp = NULL;
	for(p = list[num%BIRTHDAY]; p != NULL && p->num < num; p = p->next)
		tmp = p;

	item = (hash*)malloc(sizeof(hash));
	item->num = num;
	item->next = p;
	if(tmp == NULL)
		list[num%BIRTHDAY] = item;
	else
		tmp->next = item;
}

void search(hash **list, int num){
	hash *p;
	for(p = list[num%BIRTHDAY]; p != NULL && p->num <= num; p = p->next){
		if(p->num == num)
			possible();
	}
}

void possible(){
	printf("POSSIBLE");
	exit(0);
}
//  [javascript]
"use strict"
function Main(stdin){
let stdout = [];

stdin = stdin.trim().split("\n");
let n = parseInt(stdin[0].split(" ")[0])
let m = parseInt(stdin[0].split(" ")[1])

let ab = [];
for (let i = 0; i < m; i++){
    ab.push(Array.from(stdin[i+1].split(" "), x => parseInt(x)))
}

let s1 = new Set();
for (let i = 0; i < m; i++){
    if (ab[i][0] === 1){ s1.add(ab[i][1]) }
}

let s2 = new Set();
for (let i = 0; i < m; i++){
    if (ab[i][1] === n){ s2.add(ab[i][0]) }
}

function intersection(setA, setB) {
    var _intersection = new Set();
    for (var elem of setB) {
        if (setA.has(elem)) {
            _intersection.add(elem);
        }
    }
    return _intersection;
}

if (intersection(s1,s2).size > 0){
    stdout.push("POSSIBLE")
}else{
    stdout.push("IMPOSSIBLE")
}


console.log(stdout.join("\n"));
return stdout
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"))
//  [javascript]
console.log((args=>{
  const [[N,M],...tmp] = args.trim().split`\n`.map(r=>r.split` `.map(v=>v|0));
  const G = Array.from({length:N+1},_=>[]);
  for ( let i = 0; i < M; i++ ) {
    const [a,b] = tmp[i];
    G[a].push(b);
    G[b].push(a);
  }
  for ( const x of G[1] ) {
    for ( const t of G[x] ) {
      if ( t === N ) return 'POSSIBLE';
    }
  }
  return 'IMPOSSIBLE';
})(require('fs').readFileSync('/dev/stdin', 'utf8')));
//  [javascript]
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input, "index" : 0, "max" : input.length,
  "hasNext" : function(){return (this.index < this.max);},
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  }
}
Main();
function next(){return obj.next();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = nextIntArray();
  var N = one[0];
  var M = one[1];
  var fromOne = new Set();
  var toN = new Set();
  for(var i = 0; i < M; i++){
    var tmp = nextIntArray();
    if(tmp[0] == 1){
       fromOne.add(tmp[1]);
    }
    if(tmp[1] == N){
       toN.add(tmp[0]);
    }
  }
  myerr(fromOne);
  myerr(toN);
  var toNlist = Array.from(toN);
  for(var i = 0; i < toNlist.length; i++){
    if(fromOne.has(toNlist[i])){
       myout("POSSIBLE");
      return;
    }
  }
  myout("IMPOSSIBLE");
}
//  [go]
package main

import "fmt"

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	m := make(map[int][]int, N)
	var from, to int
	for i := 0; i < M; i++ {
		fmt.Scan(&from, &to)
		m[from] = append(m[from], to)
	}

	found := false
	if len(m[1]) == 0 {
		found = false
	} else {
	L:
		for _, v := range m[1] {
			for _, w := range m[v] {
				if w == N {
					found = true
					break L
				}
			}
		}
	}
	if found {
		fmt.Println("POSSIBLE")
	} else {
		fmt.Println("IMPOSSIBLE")
	}
}
//  [go]
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Thu Jan 10 22:07:30 2019
//
package main

import "fmt"

type graph [][]int

func dfs(from int, to int, g graph, n int) bool {
	if n == 0 {
		for i := range g[from] {
			if g[from][i] == to {
				return true
			}
		}
		return false
	}

	for i := range g[from] {
		if dfs(g[from][i], to, g, n-1) {
			return true
		}
	}
	return false
}

func main() {
	var N, M int
	fmt.Scan(&N, &M)

	g := make(graph, N+1)
	for i := 0; i < M; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		g[a] = append(g[a], b)
		g[b] = append(g[b], a)
	}

	if dfs(1, N, g, 1) {
		fmt.Println("POSSIBLE")
	} else {
		fmt.Println("IMPOSSIBLE")
	}
}
//  [go]
package main

import (
	"fmt"
	"os"
)

var (
	n, m int
	a, b int
	mp   = make(map[int][]int)
)

func main() {
	fmt.Scan(&n, &m)
	for i := 0; i < m; i++ {
		fmt.Scan(&a, &b)
		mp[a] = append(mp[a], b)
	}

	for _, v := range mp[1] {
		for _, w := range mp[v] {
			if w == n {
				fmt.Println("POSSIBLE")
				os.Exit(0)
			}
		}
	}

	fmt.Println("IMPOSSIBLE")
}
//  [ruby]
def cc068
    n,m = gets.chomp.split(/\s/).map{|x| x.to_i}

    ab = {}
    for i in 1..m
        a,b = gets.chomp.split(/\s/).map{|x| x.to_i}
        if ab.has_key?(a)
            ab[a].push(b)
        else
            ab[a] = [b]
        end
    end

    ab[1].each do |one|
        next unless ab.has_key?(one)

        if ab[one].index(n)
            puts 'POSSIBLE'
            exit
        end
    end

    puts 'IMPOSSIBLE'
end

cc068
//  [ruby]
N,M = gets.split.map(&:to_i)
$es = {}
M.times{
  a,b = gets.split.map(&:to_i)
  $es[a] ||= {}; $es[b] ||= {}
  $es[a][b] = $es[b][a] = 1
}

def r(a,n = 0)
  if a == N
    puts "POSSIBLE"; exit
  end
  return if n >= 2
  $es[a].keys.each{ |b|
    r(b, n+1)
  }
end

r(1)
puts "IMPOSSIBLE"
//  [ruby]
(N, M), *ABs = readlines.map{|l| l.split.map(&:to_i)}

G = (ABs + ABs.map(&:reverse)).group_by(&:first).map{|k, v| [k, v.map(&:last)]}.to_h
G.default = []
puts (G[1] & G[N]).empty? ? 'IMPOSSIBLE' : 'POSSIBLE'
//  [rust]
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (N, M): (usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };
    let (a, b): (Vec<usize>, Vec<usize>) = {
        let (mut a, mut b) = (vec![], vec![]);
        for _ in 0..M {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            a.push(iter.next().unwrap().parse().unwrap());
            b.push(iter.next().unwrap().parse().unwrap());
        }
        (a, b)
    };

    let G = {
        let mut G = vec![std::collections::HashSet::new(); N + 1];
        for i in 0..M {
            G[a[i]].insert(b[i]);
            G[b[i]].insert(a[i]);
        }
        G
    };

    let mut dp = vec![100000000; N + 1];
    let mut q = std::collections::BinaryHeap::new();
    q.push((0i64, 1));
    dp[1] = 0;
    while !q.is_empty() {
      let (c, i) = q.pop().unwrap();
      let c = -c;
      for &j in &G[i] {
        if c + 1 < dp[j] {
          q.push((-(c + 1), j));
          dp[j] = c + 1;
        }
      }
    }
    let ans = if dp[N] <= 2 { "POSSIBLE" } else { "IMPOSSIBLE" };

    println!("{}", ans);
}
//  [rust]
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (N, M): (usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };
    let (a, b): (Vec<usize>, Vec<usize>) = {
        let (mut a, mut b) = (vec![], vec![]);
        for _ in 0..M {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            a.push(iter.next().unwrap().parse().unwrap());
            b.push(iter.next().unwrap().parse().unwrap());
        }
        (a, b)
    };

    let mut S = vec![std::collections::HashSet::new(); N + 1];
    for i in 0..M {
        S[a[i]].insert(b[i]);
        S[b[i]].insert(a[i]);
    }

    let ans = if (2..N).any(|i| S[i].contains(&1) && S[i].contains(&N)) {
        "POSSIBLE"
    } else {
        "IMPOSSIBLE"
    };

    println!("{}", ans);
}
//  [rust]
use std::io::*;
use std::str::FromStr;
use std::cmp;
use std::collections::HashMap;
use std::collections::HashSet;
use std::char;
use std::cmp::{min, max};
use itertools::Itertools;
use std::ops::{Add, AddAssign};
use num_integer::{Integer, gcd, lcm};
use std::collections::VecDeque;
use smallvec::alloc::collections::LinkedList;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn read_tuple2<T: FromStr, S: FromStr>() -> (T, S) {
    let a = read();
    let b = read();
    (a, b)
}

fn read_tuple3<T: FromStr, S: FromStr, R: FromStr>() -> (T, S, R) {
    let a = read();
    let b = read();
    let c = read();
    (a, b, c)
}

fn lower_bound<T: Copy, F>(v: &Vec<T>, f: F) -> Option<usize> where
    F: Fn(T) -> bool
{
    let mut left = 0;
    let mut right = v.len() - 1;
    if !f(v[left]) {
        return None;
    }
    if f(v[right]) {
        return Some(right);
    }
    loop {
        if right - left == 1 {
            return Some(left);
        }
        let mid = (left + right) / 2;
        if f(v[mid]) {
            left = mid;
        } else {
            right = mid;
        }
    }
}

fn main() {
    let (n, m):(u32, u32) = read_tuple2();
    let routes:Vec<(u32, u32)> = (0..m).map(|_|read_tuple2()).collect();
    let mut route_maps = HashMap::new();
    for (from, to) in routes {
        let mut ent =
            route_maps.entry(from).or_insert(LinkedList::new());
        (*ent).push_back(to);
        let mut ent =
            route_maps.entry(to).or_insert(LinkedList::new());
        (*ent).push_back(from);
    }
    let mut snd = LinkedList::new();
    for i in route_maps.entry(1).or_insert(LinkedList::new()) {
        if *i == n {
            println!("POSSIBLE");
            return;
        }
        snd.push_back(*i);
    }
    for i in snd {
        for j in route_maps.entry(i).or_insert(LinkedList::new()) {
            if *j == n {
                println!("POSSIBLE");
                return;
            }
        }
    }
    println!("IMPOSSIBLE");
}
//  [swift]
let input = readLine()!.characters.split(" ").map{Int(String($0))!}
let (N, M) = (input[0], input[1])
var arr = (0..<N).map{_ in 0}
 
for _ in 0..<M {
  let input = readLine()!.characters.split(" ").map{Int(String($0))!}
  let (a, b) = (input[0], input[1])
  if a == 1 {
    arr[b] += 1
  }
  if b == N {
    arr[a] += 1
  }
}
print((arr.contains(2) ? "" : "IM") + "POSSIBLE")
//  [python]
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline

sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    X = 0
    AB = []
    for _ in range(N):
        A, B = map(int, readline().split())
        X -= B
        AB.append(A + B)
    AB.sort(reverse=True)
    for ab in AB[::2]:
        X += ab
    print(X)


if __name__ == '__main__':
    main()
//  [python]
from collections import deque
from collections import OrderedDict

def main():
    N, *AB = map(int, open(0).read().split())
    C = [0]*N
    ans = 0
    for i in range(N):
        a = AB[i * 2 + 0]
        b = AB[i * 2 + 1]
        C[i] = a + b
        ans -= b
    C.sort(reverse=True)
    eaten = (N + 1) // 2
    for i in range(eaten):
        ans += C[2*i]
    print(ans)

if __name__ == '__main__':
    main()
//  [python]
N, *AB = map(int, open(0).read().split())
AB = [(a, b) for a, b in zip(*[iter(AB)] * 2)]
AB.sort(key=lambda x: x[0] + x[1], reverse=True)
ans = sum(a for a, _ in AB)
for a, b in AB[1::2]:
    ans -= a + b
print(ans)
//  [python]
n = input()
dishes = []
for i in range(int(n)):
    tmp = [int(each) for each in input().split()]
    dishes.append((abs(tmp[0] + tmp[1]), tmp[0], tmp[1]))

dishes = sorted(dishes, key=lambda x: x[0], reverse=True)

point = [0, 0]
player = 0
while len(dishes) > 0:
    dish = dishes.pop(0)
    point[player] += dish[player + 1]
    player = int(not player)
print(point[0] - point[1])
//  [python]
N = int(input())
A = []
B = []
v = []
res = 0

for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
    v.append((i,a+b))

a=sorted(v,key = lambda x:x[1],reverse = True)

for i in range(N):
    tmp=a.pop(0)[0]
    if i%2==0:
        res += A[tmp]
    else:
        res -= B[tmp]

print(res)
//  [python]
#!usr/bin/env python3
from collections import defaultdict
import math
def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()
def IIR(n): return [II() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
mod = 1000000007

#A
"""
n,a,b = LI()
ans = [min(a,b),max(0,a+b-n)]
print(ans[0],ans[1])
"""

#B
"""
n = II()
a = S()
b = S()
c = S()
ans = 0
for i in range(n):
    if a[i] == b[i]:
        if b[i] == c[i]:
            continue
        else:
            ans += 1
    else:
        if b[i] == c[i] or c[i] == a[i]:
            ans += 1
        else:
            ans += 2
print(ans)
"""

#C
n = II()
c = LIR(n)
c.sort(key = lambda x:-x[0]-x[1])
ans = 0
i = 0
for i in range(n):
    x,y = c.pop(0)
    if i%2 == 0:
        ans += x
    else:
        ans -= y
print(ans)

#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T
//  [java]
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int N = in.i();
        int[] sum = new int[N];

        long ans = 0;
        for (int i = 0; i < N; i++) {
            int a = in.i();
            int b = in.i();
            sum[i] = a + b;
            ans += -b;
        }
        Arrays.sort(sum);

        for (int i = N - 1; i >= 0; i -= 2) {
            ans += sum[i];
        }
        
        out.println(ans);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}
//  [java]




import java.util.ArrayList;
import java.util.Comparator;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ArrayList<Dish> li = new ArrayList<>();
		
		for (int i=0;i<n;i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			Dish d = new Dish();
			d.a=a;
			d.b=b;
			
			li.add(d);
		}
		
		li.sort(Comparator.comparing((d) -> (d.a+d.b), Comparator.reverseOrder()));
		
		long ans = 0;
		
		for (int i=0;i<n;i++) {
			if (i%2==0) {
				ans += li.get(0).a;
				li.remove(0);
			} else {
				ans -= li.get(0).b;
				li.remove(0);
			}
		}

		System.out.println(ans);
	}



}

class Dish  {
	int a;
	int b;
}
//  [java]
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList<Long> List = new ArrayList<>();
        long bi_sum =0;
        for(int a=0;a<N;a++){
            long ai = sc.nextLong();
            long bi = sc.nextLong();
            long sum = ai+bi;
            bi_sum+=bi;
            List.add(sum);
        }
        Collections.sort(List,Comparator.reverseOrder());
        long sum_opt =0;
        sum_opt -=bi_sum;
        while(List.size()!=0){
            sum_opt+=List.get(0);
            List.remove(0);
            if(List.size()!=0) List.remove(0);
        }
        System.out.println(sum_opt);
    }
}
//  [java]

import java.util.LinkedList;
import java.util.Scanner;

public class Main {

	static Scanner in = new Scanner(System.in);

	public static void main(String[] args) {
		int N = in.nextInt();
		LinkedList<Long[]> list = new LinkedList<>();
		for (int i = 0; i < N; i++) {
			long A = in.nextLong();
			long B = in.nextLong();
			list.add(new Long[] {A, B, 0L});
		}
		LinkedList<Long[]>list2 = new LinkedList<>(list);
		list.sort((a, b)->{
			int compare = Long.compare( (b[1] + b[0]), (a[1] + a[0]));
			if (compare != 0) {
				return compare;
			}
			return Long.compare(b[1], a[1]);
		});
		list2.sort((a, b)->{
			int compare = Long.compare( (b[1] + b[0]), (a[1] + a[0]));
			if (compare != 0) {
				return compare;
			}
			return Long.compare(b[0], a[0]);
		});

		long happy = 0;
		while (!list.isEmpty()) {
			Long[] ls = list.pollFirst();
			while (ls != null && ls[2] != 0) {
				ls = list.pollFirst();
			}
			if (ls == null) {
				break;
			}
			happy += ls[0];
			ls[2] = 1L;

			ls = list2.pollFirst();
			while (ls != null && ls[2] != 0) {
				ls = list.pollFirst();
			}
			if (ls == null) {
				break;
			}
			happy -= ls[1];
			ls[2] = 1L;
		}
		System.out.println(happy);
	}
}