fun main(args: Array<String>) {
    main { readLine() }
}

fun main(readLine: () -> String?) {
    val problem = readProblem(readLine)
    val solution = solve(problem)
    printSolution(solution)
}

// READ PROBLEM

private fun readProblem(readLine: () -> String?): Problem {
    val input = (readLine() + readLine() + readLine())
    return Problem(input.map(::charToPlayer))
}

private fun charToPlayer(c: Char): Player? {
    when (c) {
        'X' -> return Player.X
        '0' -> return Player.O
        else -> return null
    }
}

private class Problem(val board: List<Player?>) {
    override fun toString(): String {
        return board.joinToString(" ")
    }

    fun countX(): Int {
        return board.filter { it == Player.X }.count()
    }

    fun countO(): Int {
        return board.filter { it == Player.O }.count()
    }

    fun hasThreeX(): Boolean {
        val xs = board.map { it == Player.X }
        return isWinning(xs)
    }

    fun hasThreeO(): Boolean {
        val os = board.map { it == Player.O }
        return isWinning(os)
    }

    private fun isWinning(b: List<Boolean>): Boolean {
        return (b[0] && b[1] && b[2])
                || (b[3] && b[4] && b[5])
                || (b[6] && b[7] && b[8])
                || (b[0] && b[3] && b[6])
                || (b[1] && b[4] && b[7])
                || (b[2] && b[5] && b[8])
                || (b[0] && b[4] && b[8])
                || (b[2] && b[4] && b[6])
    }
}

private enum class Player {
    X, O
}

// SOLVE PROBLEM

private fun solve(prob: Problem): Solution {
    // x - it's the first player
    // o - it's the second player
    val xNo = prob.countX()
    val oNo = prob.countO()
    val xWon = prob.hasThreeX()
    val oWon = prob.hasThreeO()

    when {
        (xNo < oNo) -> return Solution.ILLEGAL
        (xNo > (oNo + 1)) -> return Solution.ILLEGAL
        (xWon && oWon) -> return Solution.ILLEGAL
        (xWon && (xNo > oNo)) -> return Solution.FIRST_WON
        (xWon) -> return Solution.ILLEGAL
        (oWon && (xNo == oNo)) -> return Solution.SECOND_WON
        (oWon) -> return Solution.ILLEGAL
        (xNo + oNo == 9) -> return Solution.DRAW
        (xNo == oNo) -> return Solution.FIRST
        (xNo > oNo) -> return Solution.SECOND
        else -> return Solution.ILLEGAL
    }
}

// PRINT SOLUTION

private enum class Solution(val txt: String) {
    FIRST("first"),
    SECOND("second"),
    ILLEGAL("illegal"),
    FIRST_WON("the first player won"),
    SECOND_WON("the second player won"),
    DRAW("draw");

    fun print(consumer: (String) -> Unit) {
        consumer(txt)
    }
}

private fun printSolution(solution: Solution) {
    solution.print(::println)
}


import java.lang.Exception

fun main() {
    // 0 || X || .
    var num1 = 0 //The first player draws X goes
    var num2 = 0 //The second player draws 0 goes
    var spaceNum = 0 // space are '.'
    val table = arrayListOf(readLine()!!.toCharArray())
    var isFull = !table[0].any() { it == '.' }
    table.add(readLine()!!.toCharArray())
    isFull = isFull && !table[1].any() { it == '.' }
    table.add(readLine()!!.toCharArray())
    isFull = isFull && !table[2].any() { it == '.' }
    for (k in table.indices) {
        for (i in table[k].indices) {
            when {
                table[k][i] == 'X' -> {
                    num1++
                }
                table[k][i] == '0' -> {
                    num2++
                }
                table[k][i] == '.' -> {
                    spaceNum++
                }
            }
        }
    }
    //println("num1 : $num1, num2 : $num2")
    if (num1 - num2 != 0 && num1 - num2 != 1) {
        println("illegal")
        return
    }
    val checkChar = if (num1 == num2) {
        '0'
    } else {
        'X'
    }
    //println("check : $checkChar")
    for (i in 0..2) { // fin
        if (checkChar == table[i][0] && table[i][0] == table[i][1] && table[i][1] == table[i][2]) {
            return
        }
        if (checkChar == table[0][i] && table[0][i] == table[1][i] && table[1][i] == table[2][i]) {
            return
        }
    }
    if (checkChar == table[0][0] && table[0][0] == table[1][1] && table[1][1] == table[2][2]) {
        return
    }
    if (checkChar == table[0][2] && table[0][2] == table[1][1] && table[1][1] == table[2][0]) {
        return
    }

    if (!isFull) {
        if (num1 - num2 == 0) {
            println("first")
        } else if (num1 - num2 == 1) {
            println("second")
        }
        return
    } else {
        println("draw")
    }
}


import java.lang.Exception

fun main() {
    // 0 || X || .
    var num1 = 0 //The first player draws X goes
    var num2 = 0 //The second player draws 0 goes
    var spaceNum = 0 // space are '.'
    val table = arrayListOf(readLine()!!.toCharArray())
    var isFull = !table[0].any() { it == '.' }
    table.add(readLine()!!.toCharArray())
    isFull = isFull && !table[1].any() { it == '.' }
    table.add(readLine()!!.toCharArray())
    isFull = isFull && !table[2].any() { it == '.' }
    for (k in table.indices) {
        for (i in table[k].indices) {
            when {
                table[k][i] == 'X' -> {
                    num1++
                }
                table[k][i] == '0' -> {
                    num2++
                }
                table[k][i] == '.' -> {
                    spaceNum++
                }
            }
        }
    }
    //println("num1 : $num1, num2 : $num2")
    if (num1 - num2 != 0 && num1 - num2 != 1) {
        println("illegal")
        return
    }
    val checkChar = arrayOf('X', '0')
    var won = arrayOf(0, 0)
    for (c in 0..1) {
        for (i in 0..2) { // fin
            if (checkChar[c] == table[i][0] && table[i][0] == table[i][1] && table[i][1] == table[i][2]) {
                won[c]++
            }
            if (checkChar[c] == table[0][i] && table[0][i] == table[1][i] && table[1][i] == table[2][i]) {
                won[c]++
            }
        }
        if (checkChar[c] == table[0][0] && table[0][0] == table[1][1] && table[1][1] == table[2][2]) {
            won[c]++
        }
        if (checkChar[c] == table[0][2] && table[0][2] == table[1][1] && table[1][1] == table[2][0]) {
            won[c]++
        }
    }
    //println("check : $checkChar")

    if (won[0] >= 1 && won[1] >= 1) {
        println("illegal")
        return
    } else if (won[0] >= 1) {
        println("the first player won")
        return
    } else if (won[1] >= 1) {
        println("the second player won")
        return
    }

    if (!isFull) {
        if (num1 - num2 == 0) {
            println("first")
        } else if (num1 - num2 == 1) {
            println("second")
        }
        return
    } else {
        println("draw")
    }
}


import java.util.*
import java.math.*
import kotlin.math.*

fun readLn()=readLine()!!
fun readInt()=readLn().toInt()
fun readInts()=readLn().split(" ").map{it.toInt()}
fun readLong()=readLn().toLong()
fun readLongs()=readLn().split(" ").map{it.toLong()}

val out=mutableListOf<String>()
fun printLine(s:String){out.add(s)}
fun output(){println(out.joinToString("\n"))}

fun TreeMap<Char,Int>.add(i:Char,x:Int){
    set(i,getOrDefault(i,0)+x)
}
fun main(){
    var a=Array(3){readLn().toCharArray()}
    var cnt=TreeMap<Char,Int>()
    for(j in 0..2)for(i in a[j])cnt.add(i,1)
    var o=cnt.getOrDefault('0',0)
    var x=cnt.getOrDefault('X',0)
    if(o>x || x>o+1)printLine("illegal")
    else{
        fun win(c:Char):Boolean{
            for(j in 0..2)if(a[j][0]==c&&a[j][1]==c&&a[j][2]==c)return true
            for(j in 0..2)if(a[0][j]==c&&a[1][j]==c&&a[2][j]==c)return true
            if(a[0][0]==c&&a[1][1]==c&&a[2][2]==c)return true
            if(a[2][0]==c&&a[1][1]==c&&a[0][2]==c)return true
            return false
        }
        if(win('X')&&win('0'))printLine("illegal")
        else{
            if(win('X')){
                var ok=false
                for(i in 0..2)for(j in 0..2){
                    a[i][j]='.'
                    if(!win('X'))ok=true
                    a[i][j]='X'
                }
                if(ok&&x==o+1)printLine("the first player won")
                else printLine("illegal")
            }else if(win('0')){
                var ok=false
                for(i in 0..2)for(j in 0..2){
                    a[i][j]='.'
                    if(!win('0'))ok=true
                    a[i][j]='0'
                }
                if(ok&&x==o)printLine("the second player won")
                else printLine("illegal")
            }else{
                if(x+o==9)printLine("draw")
                else if(x>o)printLine("second")
                else printLine("first")
            }
        }
    }
    output()
}


fun main(args: Array<String>) {
    main { readLine() }
}

fun main(readLine: () -> String?) {
    val problem = readProblem(readLine)
    val solution = solve(problem)
    printSolution(solution)
}

// READ PROBLEM

private fun readProblem(readLine: () -> String?): Problem {
    val input = (readLine() + readLine() + readLine())
    return Problem(input.map(::charToPlayer))
}

private fun charToPlayer(c: Char): Player? {
    when (c) {
        'X' -> return Player.X
        '0' -> return Player.O
        else -> return null
    }
}

private class Problem(val board: List<Player?>) {
    override fun toString(): String {
        return board.joinToString(" ")
    }

    fun countX(): Int {
        return board.filter { it == Player.X }.count()
    }

    fun countO(): Int {
        return board.filter { it == Player.O }.count()
    }

    fun hasThreeX(): Boolean {
        val xs = board.map { it == Player.X }
        return isWinning(xs)
    }

    fun hasThreeO(): Boolean {
        val os = board.map { it == Player.O }
        return isWinning(os)
    }

    private fun isWinning(b: List<Boolean>): Boolean {
        return (b[0] && b[1] && b[2])
                || (b[3] && b[4] && b[5])
                || (b[6] && b[7] && b[8])
                || (b[0] && b[3] && b[6])
                || (b[1] && b[4] && b[7])
                || (b[2] && b[5] && b[8])
                || (b[0] && b[4] && b[8])
                || (b[2] && b[4] && b[6])
    }
}

private enum class Player {
    X, O
}

// SOLVE PROBLEM

private fun solve(prob: Problem): Solution {
    // x - it's the first player
    // o - it's the second player
    val xNo = prob.countX()
    val oNo = prob.countO()
    val xWon = prob.hasThreeX()
    val oWon = prob.hasThreeO()

    when {
        (xNo < oNo) -> return Solution.ILLEGAL
        (xNo > (oNo + 1)) -> return Solution.ILLEGAL
        (xWon && oWon) -> return Solution.ILLEGAL
        (xWon && (xNo > oNo)) -> return Solution.FIRST_WON
        (xWon) -> return Solution.ILLEGAL
        (oWon && (xNo == oNo)) -> return Solution.SECOND_WON
        (oWon) -> return Solution.ILLEGAL
        (xNo == oNo) -> return Solution.FIRST
        (xNo > oNo) -> return Solution.SECOND
        else -> return Solution.ILLEGAL
    }
}

// PRINT SOLUTION

private enum class Solution(val txt: String) {
    FIRST("first"),
    SECOND("second"),
    ILLEGAL("illegal"),
    FIRST_WON("the first player won"),
    SECOND_WON("the second player won"),
    DRAW("draw");

    fun print(consumer: (String) -> Unit) {
        consumer(txt)
    }
}

private fun printSolution(solution: Solution) {
    solution.print(::println)
}


import java.lang.Exception

fun main() {
    // 0 || X || .
    var num1 = 0 //The first player draws X goes
    var num2 = 0 //The second player draws 0 goes
    var spaceNum = 0 // space are '.'
    val table = arrayListOf(readLine()!!.toCharArray())
    var isFull = !table[0].any() { it == '.' }
    table.add(readLine()!!.toCharArray())
    isFull = isFull && !table[1].any() { it == '.' }
    table.add(readLine()!!.toCharArray())
    isFull = isFull && !table[2].any() { it == '.' }
    for (k in table.indices) {
        for (i in table[k].indices) {
            when {
                table[k][i] == 'X' -> {
                    num1++
                }
                table[k][i] == '0' -> {
                    num2++
                }
                table[k][i] == '.' -> {
                    spaceNum++
                }
            }
        }
    }
    //println("num1 : $num1, num2 : $num2")
    if (num1 - num2 != 0 && num1 - num2 != 1) {
        println("illegal")
        return
    }
    val checkChar = arrayOf('X', '0')
    var won = arrayOf(0, 0)
    for (c in 0..1) {
        for (i in 0..2) { // fin
            if (checkChar[c] == table[i][0] && table[i][0] == table[i][1] && table[i][1] == table[i][2]) {
                won[c]++
            }
            if (checkChar[c] == table[0][i] && table[0][i] == table[1][i] && table[1][i] == table[2][i]) {
                won[c]++
            }
        }
        if (checkChar[c] == table[0][0] && table[0][0] == table[1][1] && table[1][1] == table[2][2]) {
            won[c]++
        }
        if (checkChar[c] == table[0][2] && table[0][2] == table[1][1] && table[1][1] == table[2][0]) {
            won[c]++
        }
    }
    //println("check : $checkChar")

    if (won[0] >= 1 && won[1] >= 1) {
        println("illegal")
        return
    } else if (won[0] == 1) {
        println("the first player won")
    } else if (won[1] == 1) {
        println("the second player won")
    }

    if (!isFull) {
        if (num1 - num2 == 0) {
            println("first")
        } else if (num1 - num2 == 1) {
            println("second")
        }
        return
    } else {
        println("draw")
    }
}


import java.util.Scanner

fun main() {

    val sc = Scanner(System.`in`)
    val x : Int = sc.nextInt()
    val t : Int = sc.nextInt()
    val a : Int = sc.nextInt()
    val b : Int = sc.nextInt()
    val da : Int = sc.nextInt()
    val db : Int = sc.nextInt()

    for (i in 0 until t) {
        for (j in 0 until t) {
            if ((a - i * da) + (b - j * db) == x || a - i * da == x || b - j * db == x || x == 0) {
                print("YES")
                return
            }
        }
    }

    print("NO")

}


import java.util.Scanner
import java.util.Arrays
fun main(){
    val input=Scanner(System.`in`)
    var x:Int=input.nextInt()
    var t:Int=input.nextInt()
    var a:Int=input.nextInt()
    var b:Int=input.nextInt()
    var c:Int=input.nextInt()
    var d:Int=input.nextInt()
    for(i in 0 until t){
        for(j in 0 until t){
            if(a-(i*c)+b-(j*d)==x||a-(i*c)==x||b-(j*d)==x||x==0){
                print("YES")
                return
            }
        }
    }
    print("NO")
}


import java.util.Scanner

fun main() {

    val sc = Scanner(System.`in`)
    val x : Int = sc.nextInt()
    val t : Int = sc.nextInt()
    val a : Int = sc.nextInt()
    val b : Int = sc.nextInt()
    val da : Int = sc.nextInt()
    val db : Int = sc.nextInt()

    for (i : Int in 0 until t) {
        for (j : Int in 0 until t) {
            if ((a - i * da) + (b - j * db) == x || a - i * da == x || b - j * db == x || x == 0) {
                print("YES")
                return
            }
        }
    }

    print("NO")

}


import java.util.HashSet

fun separate(s: IntArray, q: String): IntArray {
    for(sp in s)
        if(sp >= q.length)
            return IntArray(0, { it })

    val c = HashSet<Char>()

    c.add(q[0])
    for(i in 0..s.size - 1) {
        if(q[s[i]] in c) {
            s[0]++

            for(j in 1..s.size - 1) {
                if(s[j] == s[j - 1]) {
                    s[j - 1] = 0
                    s[j]++
                }
            }

            return separate(s, q)
        }
        c.add(q[s[i]])
    }

    return s
}

fun main(args: Array<String>) {
    val k = readLine()!!.toInt()
    val q = readLine() ?: ""

    if(k > 1) {
        val s = separate(IntArray(k - 1, { it + 1 }), q)

        if(s.size > 0) {
            println("YES")
            println(q.subSequence(0, s[0]))

            for(i in 0..s.size - 2) {
                println(q.subSequence(s[i], s[i + 1]))
            }

            println(q.subSequence(s[s.size - 1], q.length))
        } else {
            println("NO")
        }
    } else {
        println("YES")
        println(q)
    }
}


import java.util.HashSet

fun separate(s: IntArray, q: String): IntArray {
    if(s[s.size - 1] == q.length)
        return IntArray(0, { it })

    val c = HashSet<Char>()

    c.add(q[0])
    for(i in 0..s.size - 1) {
        if(q[s[i]] in c) {
            s[0]++

            for(j in 1..s.size - 1) {
                if(s[j] == s[j - 1]) {
                    s[j - 1] = 0
                    s[j]++
                }
            }

            return separate(s, q)
        }
        c.add(q[s[i]])
    }

    return s
}

fun main(args: Array<String>) {
    val k = readLine()!!.toInt()
    val q = readLine() ?: ""

    if(k > 1) {
        val s = separate(IntArray(k - 1, { it + 1 }), q)

        if(s.size > 0) {
            println("YES")
            println(q.subSequence(0, s[0]))

            if(s.size > 2)
                for(i in 1..s.size - 2) {
                    println(q.subSequence(s[i], s[i + 1]))
                }

            println(q.subSequence(s[s.size - 1], q.length))
        } else {
            println("NO")
        }
    } else {
        println("YES")
        println(q)
    }
}


import java.util.HashSet

fun separate(s: IntArray, q: String): IntArray {
    if(s[s.size - 1] == q.length)
        return IntArray(0, { it })

    val c = HashSet<Char>()

    c.add(q[0])
    for(i in 0..s.size - 1) {
        if(q[s[i]] in c) {
            s[0]++

            for(j in 1..s.size - 1) {
                if(s[j] == s[j - 1]) {
                    s[j - 1] = 0
                    s[j]++
                }
            }

            return separate(s, q)
        }
        c.add(q[s[i]])
    }

    return s
}

fun main(args: Array<String>) {
    val k = readLine()!!.toInt()
    val q = readLine() ?: ""

    if(k > 1) {
        val s = separate(IntArray(k - 1, { it + 1 }), q)

        if(s.size > 0) {
            println("Yes")
            println(q.subSequence(0, s[0]))

            if(s.size > 2)
                for(i in 1..s.size - 2) {
                    println(q.subSequence(s[i], s[i + 1]))
                }

            println(q.subSequence(s[s.size - 1], q.length))
        } else {
            println("No")
        }
    } else {
        println("Yes")
        println(q)
    }
}


import java.util.HashSet

fun main(args: Array<String>) {
    val k = readLine()!!.toInt()
    val q = readLine() ?: ""

    if(k > 1) {
        var s = IntArray(k - 1, { it + 1 })

        loop@ while(s[s.size - 1] < q.length) {
            val c = HashSet<Char>()

            c.add(q[0])
            for(i in 0 until s.size) {
                if(q[s[i]] in c) {
                    s[0]++

                    for(j in 1 until s.size) {
                        if(s[j] == s[j - 1]) {
                            s[j - 1] = j
                            s[j]++
                        }
                    }

                    continue@loop
                }
                c.add(q[s[i]])
            }

            println("YES")
            println(q.subSequence(0, s[0]))

            for(i in 0..s.size - 2) {
                println(q.subSequence(s[i], s[i + 1]))
            }

            println(q.subSequence(s[s.size - 1], q.length))

            return
        }

        println("NO")
    } else {
        println("YES")
        println(q)
    }
}


import java.util.HashSet

fun separate(s: IntArray, q: String): IntArray {
    if(s[s.size - 1] == q.length)
        return IntArray(0, { it })

    val c = HashSet<Char>()

    c.add(q[0])
    for(i in 0..s.size - 1) {
        if(q[s[i]] in c) {
            s[0]++

            for(j in 1..s.size - 1) {
                if(s[j] == s[j - 1]) {
                    s[j - 1] = 0
                    s[j]++
                }
            }

            return separate(s, q)
        }
        c.add(q[s[i]])
    }

    return s
}

fun main(args: Array<String>) {
    val k = readLine()!!.toInt()
    val q = readLine() ?: ""

    if(k > 1) {
        val s = separate(IntArray(k - 1, { it + 1 }), q)

        if(s.size > 0) {
            println("YES")
            println(q.subSequence(0, s[0]))

            for(i in 0..s.size - 2) {
                println(q.subSequence(s[i], s[i + 1]))
            }

            println(q.subSequence(s[s.size - 1], q.length))
        } else {
            println("NO")
        }
    } else {
        println("YES")
        println(q)
    }
}


import java.util.*
fun main(args:Array<String>){
    val obj=Scanner(System.`in`)
    val dna=obj.next()
    var status='z'
    var count=1
    var ins=0
    for(c in dna){
        if(c!=status) {
            if(count%2==0)
                ++ins
            count=0
            status=c
        }
        ++count
    }
    if(count%2==0) ++ins
    println(ins)
}


fun main(args:Array<String>)
{

    var counter = 1
    var insert = 0
    var c = 0.toChar()
    val input = readLine()

    input?.forEach {
        if( it == c ) {
            counter++
        }
        else {
            if( counter % 2 == 0 ) insert++
            counter = 1
            c = it
        }
    }

    if( counter % 2 == 0 ) insert++

    println(insert)
}


/*
1. O(n) - count all identical nucleos subsequences lengths and record them by incrementing ith (length of subsequence)
 integer in an array of length 100 of map of nucleos
2. go from top and increment number of inserts by 1 for each even length until max length is only uneven
 */

private const val maxDnaLength = 101

fun main() {
    val dna = readLine()!!
    var currentSequenceLength = 1
    var currentNucleo = dna[0]
    var inserts = 0
    for (i in 1 until dna.length) {
        if (dna[i] != currentNucleo) {
            if (currentSequenceLength % 2 == 0) inserts++
            currentSequenceLength = 1
            currentNucleo = dna[i]
        } else {
            currentSequenceLength++
        }
    }
    if (currentSequenceLength % 2 == 0) inserts++
    println(inserts)
}


import java.util.*
fun main(args:Array<String>){
    val obj=Scanner(System.`in`)
    val dna=obj.next()
    var status='z'
    var count=1
    var ins=0
    for(c in dna){
        if(c!=status) {
            if(count%2==0)
                ++ins
            count=0
            status=c
        }
        ++count
    }
    println(ins)
}


/*
1. O(n) - count all identical nucleos subsequences lengths and record them by incrementing ith (length of subsequence)
 integer in an array of length 100 of map of nucleos
2. go from top and increment number of inserts by 1 for each even length until max length is only uneven
 */

private const val maxDnaLength = 101

fun main() {
    val dna = readLine()!!
    var currentSequenceLength = 1
    var currentNucleo = dna[0]
    var inserts = 0
    for (i in 1 until dna.length) {
        if (dna[i] != currentNucleo) {
            if (currentSequenceLength % 2 == 0) inserts++
            currentSequenceLength = 1
            currentNucleo = dna[i]
        } else {
            currentSequenceLength++
        }
    }
    println(inserts)
}


fun main(args:Array<String>)
{

    var counter = 1
    var insert = 0
    var c = 0.toChar()
    val input = readLine()

    input?.forEach {
        if( it == c ) {
            counter++
        }
        else {
            if( counter % 2 == 0 ) insert++
            counter = 1
            c = it
        }
    }

    println(insert)
}


/*
1. O(n) - count all identical nucleos subsequences lengths and record them by incrementing ith (length of subsequence)
 integer in an array of length 100 of map of nucleos
2. go from top and increment number of inserts by 1 for each even length until max length is only uneven
 */

private const val maxDnaLength = 101

fun main() {
    val dna = readLine()!!
    val lengths = countSubsequencesLengths(dna)
    val insertsCount = lengths.values.sumBy { calculateCountOfInserts(it) }
    println(insertsCount)
}

private fun countSubsequencesLengths(dna: String): Map<Char, IntArray> {
    val subsequenceLengths = mapOf(
        'A' to IntArray(maxDnaLength),
        'T' to IntArray(maxDnaLength),
        'G' to IntArray(maxDnaLength),
        'C' to IntArray(maxDnaLength)
    )
    var currentSequenceLength = 1
    var currentNucleo = dna[0]
    for (i in 1 until dna.length) {
        if (dna[i] != currentNucleo) {
            recordLength(subsequenceLengths, currentNucleo, currentSequenceLength)
            currentNucleo = dna[i]
            currentSequenceLength = 1
        } else {
            currentSequenceLength++
        }
    }
    recordLength(subsequenceLengths, currentNucleo, currentSequenceLength)
    return subsequenceLengths
}

private fun recordLength(subsequenceLengths: Map<Char, IntArray>, currentNucleo: Char, currentSequenceLength: Int) {
    val array = subsequenceLengths.getValue(currentNucleo)
    array[currentSequenceLength] = array[currentSequenceLength].inc()
}

private fun calculateCountOfInserts(lengths: IntArray): Int {
    for (i in (lengths.size - 1) downTo 0) {
        if (lengths[i] == 0) continue
        return if (i % 2 == 0) lengths[i] else 0
    }
    return 0
}


package application

fun main(args:Array<String>)
{

    var counter = 1
    var insert = 0
    var c = 0.toChar()
    val input = readLine()

    input?.forEach {
        if( it == c ) {
            counter++
        }
        else {
            if( counter % 2 == 0 ) insert++
            counter = 1
            c = it
        }
    }

    println(insert)
}


import java.util.*
import kotlin.collections.HashMap

fun main() {
    val `in` = Scanner(System.`in`)
    val count = `in`.nextInt()
    val b = HashMap<Int, Int>()
    for (i in 0 until count) {
        b[`in`.nextInt()] = 1
    }
    var c = 0;
    b.forEach { t, u ->
        if (t > 0) {
            c++
        }
    }
    println(c)
}


import java.util.*

fun main(args: Array<String>) {
    with(Scanner(System.`in`)) {
        val n = nextInt()
        val a = Array(n, {
            nextInt()
        })
        println(a.distinct().count { it > 0 })
    }
}


//kotlinc kot.kt -include-runtime -d kot.jar
//java -jar kot.jar
import kotlin.math.*
import java.util.ArrayList
private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single int
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints
private fun readLongs() = readStrings().map { it.toLong() } // list of ints

fun main(){
	var n = readInt()
	var arr: ArrayList<Int> = ArrayList(n)
	var x  = readLine()!!.split((' ')).map(String::toInt)
	for(i in 0..n-1){
		arr.add(x[i.toInt()])
	}
	var cnt: ArrayList<Int> = ArrayList(20020)
	for(i in 0..(20020-1)){
		cnt.add(0)
	}
	var ans = 0
	for(i in 0..n-1){
		var aa = arr[i.toInt()]
		if( (arr[i.toInt()] > 0) && (cnt[aa] == 0) ) {
			ans = ans + 1
			cnt[aa] = 1
		}
	}
	println(ans)
}


import java.util.*

fun main(args: Array<String>) = with(Scanner(System.`in`)) {
    val N = nextInt()
    var a = BooleanArray(603, {false})
    var nr = 0
    for(i in 0..N-1) {
        val x = nextInt()
        if(!a[x] && x > 0) nr++;
        if(x > 0) a[x] = true
    }
    println(nr)
}


fun main() {
    fun readInts() = readLine()!!.split(" ").map(String::toInt)

    readLine()
    val input = readInts().toMutableSet()
    input.remove(0)
    print(input.size)
}


import java.util.*
import kotlin.collections.HashMap

fun main() {
    val `in` = Scanner(System.`in`)
    val count = `in`.nextInt()
    val b = HashMap<Int, Int>()
    for (i in 0 until count) {
        b[`in`.nextInt()] = 1
    }
    println(b.size)
}


//kotlinc kot.kt -include-runtime -d kot.jar
//java -jar kot.jar
import kotlin.math.*
import java.util.ArrayList
private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single int
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints
private fun readLongs() = readStrings().map { it.toLong() } // list of ints

fun main(){
	var n = readInt()
	var arr: ArrayList<Int> = ArrayList(n)
	for(i in 0..n-1){
		var x = readInt()
		arr.add(x)
	}
	var cnt: ArrayList<Int> = ArrayList(20020)
	for(i in 0..(20020-1)){
		cnt.add(0)
	}
	var ans = 0
	for(i in 0..n-1){
		var aa = arr[i.toInt()]
		if( (arr[i.toInt()] > 0) && (cnt[aa] == 0) ) {
			ans = ans + 1
			cnt[aa] = 1
		}
	}
	println(ans)

}


import java.util.Scanner
import kotlin.math.min

fun main(args : Array<String>) {

    val reader = Scanner(System.`in`)
    var a: Int = reader.nextInt()
    var b: Int = reader.nextInt()
    var x: Int = reader.nextInt()
    var y: Int = reader.nextInt()

    var d = gcd(x,y)
    x = x / d
    y = y / d

    var m = min(a/x, b/y)

    print(m*x)
    print(" ")
    print(m*y)

}

fun gcd(a:Int, b: Int):Int{
    if(b==0){
        return a
    }
    else{
        return gcd(b,a%b)
    }
}


fun main(args: Array<String>) {
    var (a, b, x, y) = readLine()!!.split(' ').map {it.toInt()}
    val g = gcd(x, y)
    x /= g; y /= g
    val k = minOf(a / x, b / y)
    println("%d %d".format(x * k, y * k))
}

fun gcd(x: Int, y: Int): Int = if (y == 0) x else gcd(y, x % y)


import java.io.*
import java.util.*

class ProblemIO(val rd: BufferedReader, val wr: PrintWriter) {
    companion object {
        fun console() = ProblemIO(BufferedReader(InputStreamReader(System.`in`)), PrintWriter(System.out))
    }

    var tok = StringTokenizer("")

    fun close() { rd.close(); wr.close() }
    fun <T> print(v: T) = wr.print(v)
    fun <T> println(v: T) = wr.println(v)
    fun readToken(): String {
        while (!tok.hasMoreTokens()) tok = StringTokenizer(rd.readLine())
        return tok.nextToken()
    }
    fun readInt() = readToken().toInt()
    fun readLong() = readToken().toLong()
    fun readLine() : String {
        tok = StringTokenizer("")
        return rd.readLine()
    }
}

fun main(args: Array<String>) {
    Thread({ val io = ProblemIO.console(); solve(io) ; io.close() }).start()
}

fun solve(io: ProblemIO) {
    val n = io.readInt()
    val bad = IntArray(n + 1)
    val good = IntArray(n + 1)
    bad[1] = 0
    good[1] = 1
    for (i in 2 .. n) {
        bad[i] = i - 1 + bad[i - 1]
        good[i] = 1 + bad[i - 1] + good[i - 1]
    }
    io.println(bad[n] + good[n])
}


fun main() {
    fun readInt() = readLine()!!.toInt()

    var n = readInt() + 1
    var selecting = 1
    var result = 0
    while (--n > 0) {
        result += 1 + selecting * n - selecting
        selecting++
    }
    print(result)
}


fun main() {
    var n = readLine()!!.toInt()
    var ans: Int = 0
    var i: Int = 1
    while (n >= 1) {
        ans += (n * i) - (i - 1)
        n--
        i++
    }
    print(ans)
}


fun main() {
    val input = readLine()!!.toInt()
    var level = 1
    var presses = input
    for (i in input downTo 1) {
        val mistakes = i - 1
        presses += level++ * mistakes
    }
    println(presses)
}


fun main() {
    val r = System.`in`.bufferedReader()
    val s = StringBuilder()
    val k = r.readLine()!!.toInt()
    //val v = r.readLine()!!.split(" ").map { it.toInt() }.sortedDescending()
    val ans = k+(1..k-1).fold(0L){acc, i -> acc + i*(k-i)}
    println(ans)
}


fun main(){
    var n = readLine()!!.toInt()
    var i=2
    var ans=n
    while (n-- > 1){
        ans+= (n-1)*i +1
        i++
    }
    println(ans)
}


fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var answer = 0
    var buttons = n
    for (i in 1..n) {
        val errors = buttons - 1
        val correct = 1
        val totalPresses = errors * i + correct
        answer += totalPresses
        buttons--
    }

    println(answer)
}


fun main(args : Array<String>) {
    val n_nullable_str = readLine()
    if (n_nullable_str == null) {
        // Do nothing ...
    } else {
        val n_str = n_nullable_str
        val n = n_str.toLong()
        val t_1 = (n * n * (n + 1)) / 2
        val t_2 = (n * (n + 1) * ((2 * n) + 1)) / 6
        val t_3 = n
        val result = t_1 - t_2 + t_3
        println("${result}")
    }
}


fun main(args: Array<String>) {
    val n= readLine()!!.toLong()
    val result=(n-1)*n*(n+1)/6+n
    println(result)
}


fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    print((n * n * (n - 1)) / 2 - (n * (n - 1) * (2 * n - 1)) / 6 + n)
}


fun main(args: Array<String>) {
    val n = readLine().toInt()
    var answer = 0
    var buttons = n
    for (i in 1..n) {
        val errors = buttons - 1
        val correct = 1
        val totalPresses = errors * i + correct
        answer += totalPresses
        buttons--
    }

    println(answer)
}


fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    println(n * (n + 1) / 2 + n -2)
}


fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    println(n * (n + 1) / 2)
}


fun main() {
    val n = readLine()!!.toInt()
    print((n*(n-1))+1)
}


fun main() {
    val n = readLine()!!.toInt()
    var ans = 1
    for (i in 2..n){
        ans*=i
    }
    print(ans+1)
}


fun main(args: Array<String>) {
    val n= readLine()!!.toInt()
    val result=(n-1)*(n*(n+1)/6)+n
    println(result)
}


fun main() {
    val n = readInt()

    println("0 0 $n")
}

fun readLn() = readLine()!!
fun readInt() = readLn().toInt()
fun readLong() = readLn().toLong()
fun readStrings() = readLn().split(' ')
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }


fun main(args: Array<String>) {

    var n = readLine()!!.toInt()

    if (n == 0) {
        print("0 0 0")
        return
    }

    var n1 = 0;
    var n2 = 1;
    var n3 = 1;

    while (n3 != n) {
        n1 = n2
        n2 = n3
        n3 = n1 + n2
    }

    print("$n1 $n2 0")

}


import java.util.Scanner
fun main(args : Array<String>) {
    val reader = Scanner(System.`in`)
    var n: Int = reader.nextInt()

    print(0)
    print(" ")
    print(0)
    print(" ")
    print(n)
}


fun main() {
    fun readInt() = readLine()!!.toInt()

    val n = readInt()
    print(
        when (n) {
            0 -> "0 0 0"
            1 -> "0 0 1"
            2 -> "0 1 1"
            else -> {
                val nums = intArrayOf(0, 1, 1, 2)
                var pos = 0
                while (nums[(pos + 2) % 4] + nums[(pos + 3) % 4] != n) {
                    nums[pos] = nums[(pos + 2) % 4] + nums[(pos + 3) % 4]
                    pos = (pos + 1) % 4
                }
                "${nums[pos]} ${nums[(pos + 1) % 4]} ${nums[(pos + 3) % 4]}"
            }
        }
    )
}


import java.util.*
import java.io.*
import java.lang.Math.*

private fun exit(msg: String) {
    println(msg)
    System.exit(0)
}
private fun exit(msg: Int) = exit(""+msg)

fun main(args: Array<String>) {
    val scan = object {
        private val reader = BufferedReader(InputStreamReader(System.`in`))
        private var tokenizer: StringTokenizer? = null

        internal operator fun next(): String {
            var t = tokenizer
            while (t == null || !t.hasMoreTokens()) {
                t = StringTokenizer(line())
            }
            return t.nextToken().apply { tokenizer = t }
        }

        internal fun int(): Int = next().toInt()
        internal fun long(): Long = next().toLong()
        internal fun double() = next().toDouble()

        internal fun line() = reader.readLine()

    }

    val n = scan.int()
    exit("0 0 $n")
}


fun main(){
val n = readLine()!!.toInt()
println("0 0 $n")
}


fun main() {
    val r = System.`in`.bufferedReader()
    val s1 = StringBuilder()
    val n = 50
    //val (n, k) = r.readLine()!!.split(" ").map { it.toInt() }
    //val v = r.readLine()!!.split(" ").map { it.toInt() }
    val fib = LongArray(n) { 0L }
    fib[1] = 1
    (2..n-1).forEach { fib[it] = fib[it-1]+fib[it-2] }
    val num = r.readLine()!!.toInt()
    when{
        num==0 -> println("0 0 0")
        num==1 -> println("0 0 1")
        else -> {
            val inedx = fib.indexOf(num.toLong())
            println("${fib[inedx-3]} ${fib[inedx-2]} ${fib[inedx-2]}")
        }
    }
}


fun main() {
    var n = readLine()!!.toInt()
    println("0 0 $n")

}


fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    println("0 0 " + n.toString())
}


fun main(args: Array<String>){
println("0 0 ${readLine()!!}")
}


fun main(){
    var n=readline()!!.toInt()
    printIn("0 0 $n")
    }


fun main(){
    var n=readline()!!.toInt()
    println("0 0 $n")
    }


fun main(){
    val n=readline()!!.toInt()
    printIn("0 0 $n")
    }


fun main(args: Array<String>) {
    print("0, 0 ${readLine()}")
}


import kotlin.math.max
import kotlin.math.min

fun main() {
    fun readInts() = readLine()!!.split(" ").map(String::toInt)

    val info = readInts()
    val smaller = info.subList(0, 4).min()!!
    val top = min(smaller, info[5] + 1)
    print(max(0, top - info[4]))
}


import kotlin.math.max
import kotlin.math.min

fun main() {
    fun readInts() = readLine()!!.split(" ").map(String::toInt)
    operator fun <E> List<E>.component6(): E = this[5]

    val info = readInts()
    val smaller = info.subList(0, 4).min()!!
    val top = min(smaller, info[5])
    print(max(0, top - info[4]))
}


fun main(args: Array<String>) {
    var b = readLine()!!.toLong()
    var ans = 1
    for (i in 2..100000) {
        if (b % i == 0L) {
            var count = 0
            while (b % i == 0L) {
                b /= i
                count ++
            }
            ans *= (count + 1)
        }
    }
    if (b != 1L) ans *= 2
    println(ans)
}


import kotlin.math.sqrt

// unable to solve it by myself. Solution on the editorial: https://codeforces.com/blog/entry/62688
fun main() {
    fun readLong() = readLine()!!.toLong()

    fun Long.factors(): MutableSet<Long> {
        val output = mutableSetOf<Long>()
        val endLoop = sqrt(this.toDouble()).toLong()
        for (i in 1L..endLoop) {
            if (this % i == 0L) {
                output.add(i)
                output.add(this / i)
            }
        }
        return output
    }

    print(readLong().factors().size)
}


fun main(){
    var b = readLine()!!.toLong()
    var ans = 0
    for(i : Long in 1..b){
        if(i * i > b) break
        if(b % i == 0L){
            ans += 1
            if(i * i != b) ans += 1
        }
    }
    print(ans)
}


fun main() {
    fun readLong() = readLine()!!.toLong()

    fun Long.primeFactors(): MutableList<Long> {
        val output = mutableListOf<Long>()
        var dividend = this
        while (dividend != 1L) {
            for (divisor in 2..dividend)
                if (dividend % divisor == 0L) {
                    output.add(divisor)
                    dividend /= divisor
                    break
                }
        }
        return output
    }

    val primeFactors = readLong().primeFactors()
    val sols = mutableListOf(1L)
    for (factor in primeFactors) {
        val last = sols.size
        for (pos in 0 until last) sols.add(sols[pos] * factor)
    }
    print(sols.toSet().size)
}


fun main() {
    fun readLong() = readLine()!!.toLong()

    fun Long.primeFactors(): MutableList<Long> {
        val output = mutableListOf<Long>()
        var dividend = this
        while (dividend != 1L) {
            for (divisor in 2..dividend)
                if (dividend % divisor == 0L) {
                    output.add(divisor)
                    dividend /= divisor
                    break
                }
        }
        return output
    }

    val primeFactors = readLong().primeFactors()
    val sols = mutableSetOf(1L)
    for (factor in primeFactors) {
        val new = mutableSetOf<Long>()
        for (sol in sols) new.add(sol * factor)
        sols.addAll(new)
    }
    print(sols.toSet().size)
}


import kotlin.math.sqrt

// unable to solve it by myself. Solution from the editorial: https://codeforces.com/blog/entry/62688
fun main() {
    fun readLong() = readLine()!!.toLong()

    fun Long.numFactors(): Long {
        if (this == 1L) return 1L

        var output = 0L
        val endLoop = sqrt(this.toDouble()).toLong()
        for (i in 1L..endLoop) if (this % i == 0L) output += 2
        return output
    }

    print(readLong().numFactors())
}


import kotlin.math.sqrt

// unable to solve it by myself. Solution from the editorial: https://codeforces.com/blog/entry/62688
fun main() {
    fun readLong() = readLine()!!.toLong()

    fun Long.numFactors(): Long {
        var output = 0L
        val endLoop = sqrt(this.toDouble()).toLong()
        for (i in 1L..endLoop) if (this % i == 0L) output += 2
        return output
    }

    print(readLong().numFactors())
}


fun main(args: Array<String>) {
    var b = readLine()!!.toLong()
    var ans = 1
    for (i in 2..100000) {
        if (b % i == 0L) {
            var count = 0
            while (b % i == 0L) {
                b /= i
                count ++
            }
            ans *= (count + 1)
        }
    }
    println(ans)
}


import kotlin.math.max

fun main() {
    fun readInts() = readLine()!!.split(" ").map(String::toInt)
    fun Int.primeFactors(): MutableMap<Int, Int> {
        val output = mutableMapOf<Int, Int>().withDefault { 0 }
        var dividend = this
        while (dividend != 1) {
            for (divisor in 2..dividend)
                if (dividend % divisor == 0) {
                    output[divisor] = output.getValue(divisor) + 1
                    dividend /= divisor
                    break
                }
        }
        return output
    }

    val (n, k) = readInts()
    var sol = 1L
    val primeFactors = n.primeFactors()
    if (2 in primeFactors) primeFactors[2] = max(0, primeFactors.getValue(2) - k)
    if (5 in primeFactors) primeFactors[5] = max(0, primeFactors.getValue(5) - k)
    for ((key, value) in primeFactors) for (i in 1..value) sol *= key
    val sb = StringBuilder(sol.toString())
    for (i in 1..k) sb.append('0')
    print(sb)
}


import java.util.*

fun pow(a: Int, b: Int) = Math.pow(a.toDouble(), b.toDouble()).toLong()
fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val k = scanner.nextInt()
    var i = 1
    while (true) {
        val p: Long = i*pow(10, k)
        if (p % n == 0.toLong()) {
            println(p)
            break
        }
        i++
    }
}


// star because
fun main() {
    fun readInts() = readLine()!!.split(" ").map(String::toInt)

    val (n, k) = readInts()
    var nn = n
    var twos = 0
    var fives = 0
    while(twos < k && nn % 2 == 0) {
        twos++
        nn /= 2
    }
    while(fives < k && nn % 5 == 0) {
        fives++
        nn /= 5
    }
    var sol = n.toLong()
    while (twos < fives) {
        sol *= 2
        twos++
    }
    while (fives < twos) {
        sol *= 5
        fives++
    }
    val sb = StringBuilder(sol.toString())
    for (i in twos until k) sb.append('0')
    print(sb)
}


import java.util.*
import kotlin.collections.*
import kotlin.math.*

val read = Scanner(System.`in`)

fun gcd(a: Long, b: Long): Long{
    return if (a == 0L) b else gcd(b%a, a)
}

fun main(){
    var n: Long = read.nextLong()
    var k: Long = read.nextLong()
    k = Math.pow(10.0, k.toDouble()).toLong()
    print(n * k / gcd(n, k))
}


import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)

    val n = sc.nextLong()
    val k = sc.nextInt()

    println(n.round(k))
}

fun Long.round(k: Int): Long {
    var t = this
    var doub = 0
    while (t % 2 == 0L) {
        doub += 1
        t /= 2
    }
    var five = 0
    while (t % 5 == 0L) {
        five += 1
        t /= 5
    }

    var res = this
    while (doub < k) {
        res *= 2
        doub += 1
    }
    while (five < k) {
        res *= 5
        five += 1
    }
    return res
}


import kotlin.math.max

fun main() {
    fun readInts() = readLine()!!.split(" ").map(String::toInt)

    var (n, k) = readInts()
    var twos = k
    var fives = k
    while(twos > 0 && n % 2 == 0) {
        twos--
        n /= 2
    }
    while(fives > 0 && n % 5 == 0) {
        fives--
        n /= 5
    }
    var sol = n
    while (twos > fives) {
        sol *= 2
        twos--
    }
    while (fives > twos) {
        sol *= 5
        fives--
    }
    val sb = StringBuilder(sol.toString())
    for (i in 1..twos) sb.append('0')
    print(sb)
}


fun main() {
    fun readInts() = readLine()!!.split(" ").map(String::toInt)

    val (d, l, v1, v2) = readInts()
    print((l - d) / (v1 + v2).toDouble())
}


@file:Suppress("NOTHING_TO_INLINE", "EXPERIMENTAL_FEATURE_WARNING", "OVERRIDE_BY_INLINE")
@file:OptIn(ExperimentalStdlibApi::class)

import java.io.PrintWriter
import kotlin.math.*
import kotlin.random.Random
import kotlin.collections.sort as _sort
import kotlin.collections.sortDescending as _sortDescending
import kotlin.io.println as iprintln

/** @author Spheniscine */
fun main() { _writer.solve(); _writer.flush() }
fun PrintWriter.solve() {
//    val startTime = System.nanoTime()

    val numCases = 1//readInt()
    case@ for(case in 1..numCases) {
//        print("Case #$case: ")

        val n = readInt()
        val m = readInt()
        val q = readInt()

        val U = IntArray(m)
        val V = IntArray(m) {
            U[it] = readInt()-1
            readInt()-1
        }

        val firstNo = IntArray(m)
        val dsu = BipartiteDSU(n)

        var l2 = m-1
        dsu.persist()
        for(i in 0 until m) {
            if(!dsu.join(U[i], V[i], OPP)) {
                for(j in i+1 until m) firstNo[j] = m
                l2 = i
                break
            }
        }
        dsu.rollback()

        fun rec(l1: Int, l2: Int, r1: Int, r2: Int) {
            if(l1 > l2) return
            val lm = (l1 + l2) / 2

            dsu.persist()

            for(i in l1 until lm) dsu.join(U[i], V[i], OPP)

            dsu.persist()

            var rm = r2
            val lim = max(lm, r1)
            while(rm > lim && dsu.join(U[rm], V[rm], OPP)) rm--
            firstNo[lm] = rm

            dsu.rollback()

            dsu.join(U[lm], V[lm], OPP)
            rec(lm+1, l2, rm, r2)

            dsu.rollback()

            for(i in rm+1..r2) dsu.join(U[i], V[i], OPP)
            rec(l1, lm-1, r1, rm)
        }

        rec(0, l2, 0, m-1)

        repeat(q) {
            val l = readInt()-1
            val r = readInt()-1

            val ans = r < firstNo[l]
            println(if(ans) "YES" else "NO")
        }
    }

//    iprintln("Time: ${(System.nanoTime() - startTime) / 1000000} ms")
}

const val SYN: Byte = 1
const val OPP: Byte = 2
const val NOR: Byte = 3

class BipartiteDSU(n: Int) {
    data class Hist(
        val u: Int,
        val v: Int,
        val szu: Int
    )

    private val hist = mutableListOf<Hist>()
    private val sav = IntList()

    private val id = IntArray(n) { it }
    private val sz = IntArray(n) { 1 }
    private val opp = BooleanArray(n)

    fun relation(u: Int, v: Int): Byte {
        var p = false
        var ru = u
        while(id[ru] != ru) {
            p = p xor opp[ru]
            ru = id[ru]
        }
        var rv = v
        while(id[rv] != rv) {
            p = p xor opp[rv]
            rv = id[rv]
        }

        return when {
            ru != rv -> NOR
            p -> OPP
            else -> SYN
        }
    }

    fun join(u: Int, v: Int, r: Byte): Boolean {
        var p = r == OPP
        var ru = u
        while(id[ru] != ru) {
            p = p xor opp[ru]
            ru = id[ru]
        }
        var rv = v
        while(id[rv] != rv) {
            p = p xor opp[rv]
            rv = id[rv]
        }

        if(ru == rv) return !p

        if(sz[ru] < sz[rv]) ru = rv.also { rv = ru }

        hist.add(Hist(ru, rv, sz[ru]))

        id[rv] = ru
        sz[ru] += sz[rv]
        opp[rv] = p
        return true
    }

    tailrec fun root(v: Int): Int =
        if(id[v] == v) v else root(id[v])

    fun size(v: Int) = sz[root(v)]

    fun persist() { sav.add(hist.size) }

    fun rollback() {
        val s = sav.pop()

        while(hist.size > s) {
            with(hist.removeAt(hist.lastIndex)) {
                id[v] = v
                sz[u] = szu
                opp[v] = false
            }
        }
    }
}

class IntList(initialCapacity: Int = 12) {
    private var _arr = IntArray(initialCapacity)
    private val capacity get() = _arr.size
    var size = 0
        private set
    inline val lastIndex get() = size - 1
    inline val indices get() = 0 until size

    constructor(copyFrom: IntArray): this(copyFrom.size) { copyFrom.copyInto(_arr); size = copyFrom.size }
    constructor(copyFrom: Collection<Int>): this(copyFrom.size) { _arr = copyFrom.toIntArray(); size = copyFrom.size }

    fun contentEquals(other: IntList): Boolean {
        return this === other || size == other.size && indices.all { this[it] == other[it] }
    }

    private fun grow(minCapacity: Int = 8) {
        val newCapacity = maxOf(minCapacity, capacity + (capacity shr 1))
        _arr = _arr.copyOf(newCapacity)
    }

    fun ensureCapacity(minCapacity: Int) { if(capacity < minCapacity) grow(minCapacity) }

    operator fun get(index: Int): Int {
        require(index in 0 until size)
        return _arr[index]
    }

    operator fun set(index: Int, value: Int) {
        require(index in 0 until size)
        _arr[index] = value
    }

    fun add(value: Int) {
        if(size == capacity) grow()
        _arr[size++] = value
    }

    fun addAll(list: IntList) {
        ensureCapacity(size + list.size)
        list._arr.copyInto(_arr, size, 0, list.size)
        size += list.size
    }

    fun add(index: Int, element: Int) {
        if(size == capacity) grow()
        _arr.copyInto(_arr, index + 1, index, size)
        size++
        set(index, element)
    }

    fun clear() { size = 0 }

    fun removeAt(index: Int): Int {
        val e = get(index)
        _arr.copyInto(_arr, index, index + 1, size)
        size--
        return e
    }

    fun indexOf(e: Int): Int {
        for(i in 0 until size) if(this[i] == e) return i
        return -1
    }

    fun remove(e: Int): Boolean {
        val i = indexOf(e)
        if(i == -1) return false
        removeAt(i)
        return true
    }

    operator fun iterator() = object: IntIterator() {
        private var pos = 0
        override fun hasNext() = pos < size
        override fun nextInt() = get(pos++)
    }

    inline fun isEmpty() = size == 0
    inline fun isNotEmpty() = size != 0

    fun pop() = _arr[--size]

    fun popToSize(s: Int) {
        require(s >= 0)
        if(s < size) size = s
    }

    fun swap(i: Int, j: Int) { val t = this[i]; this[i] = this[j]; this[j] = t }
    fun reverse() {
        for(i in 0 until size / 2) swap(i, lastIndex - i)
    }

    fun shuffle(rnd: Random = random) { for(i in lastIndex downTo 1) swap(i, rnd.nextInt(i+1)) }
    fun sort() { shuffle(); _arr._sort(0, size) }
    fun sortDescending() { sort(); reverse() }

    fun joinToString(separator: CharSequence) = if(size == 0) "" else let {
        buildString {
            append(it[0])
            for (i in 1 until size) {
                append(separator).append(it[i])
            }
        }
    }

    override fun toString() = "[" + joinToString(", ") + "]"

    fun toIntArray() = _arr.copyOf(size)
    fun toList() = List(size, ::get)

    inline fun first() = get(0)
    inline fun last() = get(lastIndex)
}

inline fun IntList(size: Int, init: (Int) -> Int) = IntList(size).apply {
    for(i in 0 until size) { add(init(i)) }
}
inline fun IntArray.toIntList() = IntList(this)
inline fun Collection<Int>.toIntList() = IntList(this)
inline fun intListOf(vararg values: Int) = IntList(values)

fun IntList.max() = (1 until size).fold(this[0]) { acc, i -> max(acc, this[i]) }
fun IntList.min() = (1 until size).fold(this[0]) { acc, i -> min(acc, this[i]) }
fun IntList.getOrNull(i: Int) = if(i in indices) get(i) else null
inline fun IntList.count(predicate: (Int) -> Boolean) = indices.count { predicate(this[it]) }
fun IntList.copyOf() = IntList(size, ::get)

/** IO */
//const val PATH = "src/main/resources/"
//@JvmField val INPUT = File(PATH + "input.txt").inputStream()
//@JvmField val OUTPUT = File(PATH + "output.txt").outputStream()
@JvmField val INPUT = System.`in`
@JvmField val OUTPUT = System.out

const val _BUFFER_SIZE = 1 shl 16
@JvmField val _buffer = ByteArray(_BUFFER_SIZE)
@JvmField var _bufferPt = 0
@JvmField var _bytesRead = 0

tailrec fun readChar(): Char {
    if(_bufferPt == _bytesRead) {
        _bufferPt = 0
        _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)
    }
    return if(_bytesRead < 0) Char.MIN_VALUE
    else {
        val c = _buffer[_bufferPt++].toChar()
        if (c == '\r') readChar()
        else c
    }
}

/** @param skipNext Whether to skip the next character (usually whitespace), defaults to true */
fun readCharArray(n: Int, skipNext: Boolean = true): CharArray {
    val res = CharArray(n) { readChar() }
    if(skipNext) readChar()
    return res
}

fun readLine(): String? {
    var c = readChar()
    return if(c == Char.MIN_VALUE) null
    else buildString {
        while(c != '\n' && c != Char.MIN_VALUE) {
            append(c)
            c = readChar()
        }
    }
}
fun readLn() = readLine()!!

fun read() = buildString {
    var c = readChar()
    while(c <= ' ') {
        if(c == Char.MIN_VALUE) return@buildString
        c = readChar()
    }
    do {
        append(c)
        c = readChar()
    } while(c > ' ')
}
fun readInt() = read().toInt()
fun readDouble() = read().toDouble()
fun readLong() = read().toLong()
fun readStrings(n: Int) = List(n) { read() }
fun readLines(n: Int) = List(n) { readLn() }
fun readInts(n: Int) = List(n) { read().toInt() }
fun readIntArray(n: Int) = IntArray(n) { read().toInt() }
fun readDoubles(n: Int) = List(n) { read().toDouble() }
fun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }
fun readLongs(n: Int) = List(n) { read().toLong() }
fun readLongArray(n: Int) = LongArray(n) { read().toLong() }

@JvmField val _writer = PrintWriter(OUTPUT, false)

/**  sort overrides to avoid quicksort attacks */

@JvmField var _random: Random? = null
val random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }

fun IntArray.sort() { shuffle(random); _sort() }
fun IntArray.sortDescending() { shuffle(random); _sortDescending() }

fun LongArray.sort() { shuffle(random); _sort() }
fun LongArray.sortDescending() { shuffle(random); _sortDescending() }

fun DoubleArray.sort() { shuffle(random); _sort() }
fun DoubleArray.sortDescending() { shuffle(random); _sortDescending() }

inline fun CharArray.sort() { _sort() }
inline fun CharArray.sortDescending() { _sortDescending() }

inline fun <T : Comparable<T>> Array<out T>.sort() = _sort()
inline fun <T : Comparable<T>> Array<out T>.sortDescending() = _sortDescending()
inline fun <T : Comparable<T>> MutableList<out T>.sort() = _sort()
inline fun <T : Comparable<T>> MutableList<out T>.sortDescending() = _sortDescending()

// import preserving junk function
@Suppress("NonAsciiCharacters") fun 雪花飄飄北風嘯嘯天地一片蒼茫() { iprintln(max(1, 2)) }

// max/min Kotlin 1.6 -> 1.4 shim
fun IntArray.max() = maxOf { it }
fun IntArray.min() = minOf { it }
fun LongArray.max() = maxOf { it }
fun LongArray.min() = minOf { it }
fun CharArray.max() = maxOf { it }
fun CharArray.min() = minOf { it }
fun <T: Comparable<T>> Iterable<T>.max() = maxOf { it }
fun <T: Comparable<T>> Iterable<T>.min() = minOf { it }
fun <T: Comparable<T>> Sequence<T>.max() = maxOf { it }
fun <T: Comparable<T>> Sequence<T>.min() = minOf { it }


@file:Suppress("NOTHING_TO_INLINE", "EXPERIMENTAL_FEATURE_WARNING", "OVERRIDE_BY_INLINE")
@file:OptIn(ExperimentalStdlibApi::class)

import java.io.PrintWriter
import kotlin.math.*
import kotlin.random.Random
import kotlin.collections.sort as _sort
import kotlin.collections.sortDescending as _sortDescending
import kotlin.io.println as iprintln

/** @author Spheniscine */
fun main() { _writer.solve(); _writer.flush() }
fun PrintWriter.solve() {
//    val startTime = System.nanoTime()

    val numCases = 1//readInt()
    case@ for(case in 1..numCases) {
//        print("Case #$case: ")

        val n = readInt()
        val m = readInt()
        val q = readInt()

        val U = IntArray(m)
        val V = IntArray(m) {
            U[it] = readInt()-1
            readInt()-1
        }

        val firstNo = IntArray(m)
        val dsu = BipartiteDSU(n)

        var l2 = m-1
        dsu.persist()
        for(i in 0 until m) {
            if(!dsu.join(U[i], V[i], OPP)) {
                for(j in i+1 until m) firstNo[j] = m
                l2 = i
                break
            }
        }
        dsu.rollback()

        fun rec(l1: Int, l2: Int, r1: Int, r2: Int) {
            if(l1 > l2) return
            val lm = (l1 + l2) / 2

            dsu.persist()

            for(i in l1 until lm) dsu.join(U[i], V[i], OPP)

            dsu.persist()

            var rm = r2
            val lim = max(lm, r1)
            while(rm > lim && dsu.join(U[rm], V[rm], OPP)) rm--
            firstNo[lm] = rm

            dsu.rollback()

            dsu.join(U[lm], V[lm], OPP)
            rec(lm+1, l2, rm, r2)

            dsu.rollback()

            for(i in rm+1..r2) dsu.join(U[i], V[i], OPP)
            rec(l1, lm-1, r1, rm)
        }

        rec(0, l2, 0, m-1)

        repeat(q) {
            val l = readInt()-1
            val r = readInt()-1

            val ans = r < firstNo[l]
            println(if(ans) "YES" else "NO")
        }
    }

//    iprintln("Time: ${(System.nanoTime() - startTime) / 1000000} ms")
}

const val SYN: Byte = 1
const val OPP: Byte = 2
const val NOR: Byte = 3

class BipartiteDSU(n: Int) {
    data class Hist(
        val u: Int,
        val v: Int,
        val idv: Int,
        val szu: Int,
        val oppv: Boolean
    )

    private val hist = mutableListOf<Hist>()
    private val sav = IntList()

    private val id = IntArray(n) { it }
    private val sz = IntArray(n) { 1 }
    private val opp = BooleanArray(n)

    fun relation(u: Int, v: Int): Byte {
        var p = false
        var ru = u
        while(id[ru] != ru) {
            p = p xor opp[ru]
            ru = id[ru]
        }
        var rv = v
        while(id[rv] != rv) {
            p = p xor opp[rv]
            rv = id[rv]
        }

        return when {
            ru != rv -> NOR
            p -> OPP
            else -> SYN
        }
    }

    fun join(u: Int, v: Int, r: Byte): Boolean {
        var p = r == OPP
        var ru = u
        while(id[ru] != ru) {
            p = p xor opp[ru]
            ru = id[ru]
        }
        var rv = v
        while(id[rv] != rv) {
            p = p xor opp[rv]
            rv = id[rv]
        }

        if(ru == rv) return !p

        if(sz[ru] < sz[rv]) ru = rv.also { rv = ru }

        hist.add(Hist(ru, rv, id[rv], sz[ru], opp[rv]))

        id[rv] = ru
        sz[ru] += sz[rv]
        opp[rv] = p
        return true
    }

    tailrec fun root(v: Int): Int =
        if(id[v] == v) v else root(id[v])

    fun size(v: Int) = sz[root(v)]

    fun persist() { sav.add(hist.size) }

    fun rollback() {
        val s = sav.pop()

        while(hist.size > s) {
            with(hist.removeAt(hist.lastIndex)) {
                id[v] = idv
                sz[u] = szu
                opp[v] = oppv
            }
        }
    }
}

class IntList(initialCapacity: Int = 12) {
    private var _arr = IntArray(initialCapacity)
    private val capacity get() = _arr.size
    var size = 0
        private set
    inline val lastIndex get() = size - 1
    inline val indices get() = 0 until size

    constructor(copyFrom: IntArray): this(copyFrom.size) { copyFrom.copyInto(_arr); size = copyFrom.size }
    constructor(copyFrom: Collection<Int>): this(copyFrom.size) { _arr = copyFrom.toIntArray(); size = copyFrom.size }

    fun contentEquals(other: IntList): Boolean {
        return this === other || size == other.size && indices.all { this[it] == other[it] }
    }

    private fun grow(minCapacity: Int = 8) {
        val newCapacity = maxOf(minCapacity, capacity + (capacity shr 1))
        _arr = _arr.copyOf(newCapacity)
    }

    fun ensureCapacity(minCapacity: Int) { if(capacity < minCapacity) grow(minCapacity) }

    operator fun get(index: Int): Int {
        require(index in 0 until size)
        return _arr[index]
    }

    operator fun set(index: Int, value: Int) {
        require(index in 0 until size)
        _arr[index] = value
    }

    fun add(value: Int) {
        if(size == capacity) grow()
        _arr[size++] = value
    }

    fun addAll(list: IntList) {
        ensureCapacity(size + list.size)
        list._arr.copyInto(_arr, size, 0, list.size)
        size += list.size
    }

    fun add(index: Int, element: Int) {
        if(size == capacity) grow()
        _arr.copyInto(_arr, index + 1, index, size)
        size++
        set(index, element)
    }

    fun clear() { size = 0 }

    fun removeAt(index: Int): Int {
        val e = get(index)
        _arr.copyInto(_arr, index, index + 1, size)
        size--
        return e
    }

    fun indexOf(e: Int): Int {
        for(i in 0 until size) if(this[i] == e) return i
        return -1
    }

    fun remove(e: Int): Boolean {
        val i = indexOf(e)
        if(i == -1) return false
        removeAt(i)
        return true
    }

    operator fun iterator() = object: IntIterator() {
        private var pos = 0
        override fun hasNext() = pos < size
        override fun nextInt() = get(pos++)
    }

    inline fun isEmpty() = size == 0
    inline fun isNotEmpty() = size != 0

    fun pop() = _arr[--size]

    fun popToSize(s: Int) {
        require(s >= 0)
        if(s < size) size = s
    }

    fun swap(i: Int, j: Int) { val t = this[i]; this[i] = this[j]; this[j] = t }
    fun reverse() {
        for(i in 0 until size / 2) swap(i, lastIndex - i)
    }

    fun shuffle(rnd: Random = random) { for(i in lastIndex downTo 1) swap(i, rnd.nextInt(i+1)) }
    fun sort() { shuffle(); _arr._sort(0, size) }
    fun sortDescending() { sort(); reverse() }

    fun joinToString(separator: CharSequence) = if(size == 0) "" else let {
        buildString {
            append(it[0])
            for (i in 1 until size) {
                append(separator).append(it[i])
            }
        }
    }

    override fun toString() = "[" + joinToString(", ") + "]"

    fun toIntArray() = _arr.copyOf(size)
    fun toList() = List(size, ::get)

    inline fun first() = get(0)
    inline fun last() = get(lastIndex)
}

inline fun IntList(size: Int, init: (Int) -> Int) = IntList(size).apply {
    for(i in 0 until size) { add(init(i)) }
}
inline fun IntArray.toIntList() = IntList(this)
inline fun Collection<Int>.toIntList() = IntList(this)
inline fun intListOf(vararg values: Int) = IntList(values)

fun IntList.max() = (1 until size).fold(this[0]) { acc, i -> max(acc, this[i]) }
fun IntList.min() = (1 until size).fold(this[0]) { acc, i -> min(acc, this[i]) }
fun IntList.getOrNull(i: Int) = if(i in indices) get(i) else null
inline fun IntList.count(predicate: (Int) -> Boolean) = indices.count { predicate(this[it]) }
fun IntList.copyOf() = IntList(size, ::get)

/** IO */
//const val PATH = "src/main/resources/"
//@JvmField val INPUT = File(PATH + "input.txt").inputStream()
//@JvmField val OUTPUT = File(PATH + "output.txt").outputStream()
@JvmField val INPUT = System.`in`
@JvmField val OUTPUT = System.out

const val _BUFFER_SIZE = 1 shl 16
@JvmField val _buffer = ByteArray(_BUFFER_SIZE)
@JvmField var _bufferPt = 0
@JvmField var _bytesRead = 0

tailrec fun readChar(): Char {
    if(_bufferPt == _bytesRead) {
        _bufferPt = 0
        _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)
    }
    return if(_bytesRead < 0) Char.MIN_VALUE
    else {
        val c = _buffer[_bufferPt++].toChar()
        if (c == '\r') readChar()
        else c
    }
}

/** @param skipNext Whether to skip the next character (usually whitespace), defaults to true */
fun readCharArray(n: Int, skipNext: Boolean = true): CharArray {
    val res = CharArray(n) { readChar() }
    if(skipNext) readChar()
    return res
}

fun readLine(): String? {
    var c = readChar()
    return if(c == Char.MIN_VALUE) null
    else buildString {
        while(c != '\n' && c != Char.MIN_VALUE) {
            append(c)
            c = readChar()
        }
    }
}
fun readLn() = readLine()!!

fun read() = buildString {
    var c = readChar()
    while(c <= ' ') {
        if(c == Char.MIN_VALUE) return@buildString
        c = readChar()
    }
    do {
        append(c)
        c = readChar()
    } while(c > ' ')
}
fun readInt() = read().toInt()
fun readDouble() = read().toDouble()
fun readLong() = read().toLong()
fun readStrings(n: Int) = List(n) { read() }
fun readLines(n: Int) = List(n) { readLn() }
fun readInts(n: Int) = List(n) { read().toInt() }
fun readIntArray(n: Int) = IntArray(n) { read().toInt() }
fun readDoubles(n: Int) = List(n) { read().toDouble() }
fun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }
fun readLongs(n: Int) = List(n) { read().toLong() }
fun readLongArray(n: Int) = LongArray(n) { read().toLong() }

@JvmField val _writer = PrintWriter(OUTPUT, false)

/**  sort overrides to avoid quicksort attacks */

@JvmField var _random: Random? = null
val random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }

fun IntArray.sort() { shuffle(random); _sort() }
fun IntArray.sortDescending() { shuffle(random); _sortDescending() }

fun LongArray.sort() { shuffle(random); _sort() }
fun LongArray.sortDescending() { shuffle(random); _sortDescending() }

fun DoubleArray.sort() { shuffle(random); _sort() }
fun DoubleArray.sortDescending() { shuffle(random); _sortDescending() }

inline fun CharArray.sort() { _sort() }
inline fun CharArray.sortDescending() { _sortDescending() }

inline fun <T : Comparable<T>> Array<out T>.sort() = _sort()
inline fun <T : Comparable<T>> Array<out T>.sortDescending() = _sortDescending()
inline fun <T : Comparable<T>> MutableList<out T>.sort() = _sort()
inline fun <T : Comparable<T>> MutableList<out T>.sortDescending() = _sortDescending()

// import preserving junk function
@Suppress("NonAsciiCharacters") fun 雪花飄飄北風嘯嘯天地一片蒼茫() { iprintln(max(1, 2)) }

// max/min Kotlin 1.6 -> 1.4 shim
fun IntArray.max() = maxOf { it }
fun IntArray.min() = minOf { it }
fun LongArray.max() = maxOf { it }
fun LongArray.min() = minOf { it }
fun CharArray.max() = maxOf { it }
fun CharArray.min() = minOf { it }
fun <T: Comparable<T>> Iterable<T>.max() = maxOf { it }
fun <T: Comparable<T>> Iterable<T>.min() = minOf { it }
fun <T: Comparable<T>> Sequence<T>.max() = maxOf { it }
fun <T: Comparable<T>> Sequence<T>.min() = minOf { it }


@file:Suppress("NOTHING_TO_INLINE", "EXPERIMENTAL_FEATURE_WARNING", "OVERRIDE_BY_INLINE")
@file:OptIn(ExperimentalStdlibApi::class)

import java.io.PrintWriter
import java.util.PriorityQueue
import kotlin.math.*
import kotlin.random.Random
import kotlin.collections.sort as _sort
import kotlin.collections.sortDescending as _sortDescending
import kotlin.io.println as iprintln

/** @author Spheniscine */
fun main() { _writer.solve(); _writer.flush() }
fun PrintWriter.solve() {
//    val startTime = System.nanoTime()

    val numCases = 1//readInt()
    case@ for(case in 1..numCases) {
//        print("Case #$case: ")

        val n = readInt()
        val m = readInt()
        val q = readInt()

        val U = IntArray(m)
        val V = IntArray(m) {
            U[it] = readInt()-1
            readInt()-1
        }

        val last = IntArray(m)
        val dsu = BipartiteDSU(n)

        var l2 = m-1
        dsu.persist()
        for(i in 0 until m) {
            if(!dsu.join(U[i], V[i], OPP)) {
                for(j in i+1 until m) last[j] = m
                l2 = i
                break
            }
        }
        dsu.rollback()

        fun rec(l1: Int, l2: Int, r1: Int, r2: Int) {
            if(l1 > l2) return
            val lm = (l1 + l2) / 2

            dsu.persist()

            for(i in l1 until lm) dsu.join(U[i], V[i], OPP)

            dsu.persist()

            var rm = r2
            val lim = max(lm-1, r1)
            while(rm > lim && dsu.join(U[rm], V[rm], OPP)) rm--
            last[lm] = rm

            dsu.rollback()

            dsu.join(U[lm], V[lm], OPP)
            rec(lm+1, l2, rm, r2)

            dsu.rollback()

            for(i in rm+1..r2) dsu.join(U[i], V[i], OPP)
            rec(l1, lm-1, r1, rm)
        }

        rec(0, l2, -1, m-1)

        repeat(q) {
            val l = readInt()-1
            val r = readInt()-1

            val ans = r < last[l]
            println(if(ans) "YES" else "NO")
        }
    }

//    iprintln("Time: ${(System.nanoTime() - startTime) / 1000000} ms")
}

class Rollback(val arr: IntArray) {
    val ihist = IntList()
    val vhist = IntList()
    val save = IntList()

    operator fun get(i: Int) = arr[i]
    operator fun set(i: Int, v: Int) {
        ihist.add(i)
        vhist.add(arr[i])
        arr[i] = v
    }

    fun persist() {
        save.add(ihist.size)
    }

    fun rollback() {
        val p = save.pop()
        while(ihist.size > p) {
            arr[ihist.pop()] = vhist.pop()
        }
    }
}

const val SYN: Byte = 1
const val OPP: Byte = 2
const val NOR: Byte = 3

class BipartiteDSU(n: Int) {
    private val id = Rollback(IntArray(n) { it })
    private val sz = Rollback(IntArray(n) { 1 })
    private val opp = Rollback(IntArray(n) { -1 })

    fun relation(u: Int, v: Int): Byte {
        val ru = root(u)
        val rv = root(v)
        return when {
            ru == rv -> SYN
            opp[ru].let { it != -1 && root(it) == rv } -> OPP
            else -> NOR
        }
    }

    fun join(u: Int, v: Int, r: Byte): Boolean {
        val ru = root(u)
        val rv = root(v)
        val cr = relation(ru, rv)
        when {
            cr == r -> return true
            cr != NOR -> return false
            else -> {
                if(r == SYN) join(ru, rv)
                else {
                    when {
                        opp[ru] != -1 -> join(opp[ru], rv)
                        opp[rv] != -1 -> join(opp[rv], ru)
                        else -> {
                            opp[ru] = rv
                            opp[rv] = ru
                        }
                    }
                }
                return true
            }
        }
    }

    tailrec fun root(v: Int): Int =
        if(id[v] == v) v else root(id[v])

    /** @return false if the two vertices are already joined, true if the join operation is successful */
    private fun join(u: Int, v: Int): Boolean {
        var ru = root(u)
        var rv = root(v)
        if(ru == rv) return false
        if(sz[ru] < sz[rv]) ru = rv.also { rv = ru }
        id[rv] = ru
        sz[ru] += sz[rv]
        if(opp[ru] != -1 && opp[rv] != -1) join(opp[ru], opp[rv])
        if(opp[rv] != -1) opp[ru] = opp[rv]
        return true
    }

    fun size(v: Int) = sz[root(v)]

    fun persist() {
        id.persist()
        sz.persist()
        opp.persist()
    }

    fun rollback() {
        id.rollback()
        sz.rollback()
        opp.rollback()
    }
}

class IntList(initialCapacity: Int = 12) {
    private var _arr = IntArray(initialCapacity)
    private val capacity get() = _arr.size
    var size = 0
        private set
    inline val lastIndex get() = size - 1
    inline val indices get() = 0 until size

    constructor(copyFrom: IntArray): this(copyFrom.size) { copyFrom.copyInto(_arr); size = copyFrom.size }
    constructor(copyFrom: Collection<Int>): this(copyFrom.size) { _arr = copyFrom.toIntArray(); size = copyFrom.size }

    fun contentEquals(other: IntList): Boolean {
        return this === other || size == other.size && indices.all { this[it] == other[it] }
    }

    private fun grow(minCapacity: Int = 8) {
        val newCapacity = maxOf(minCapacity, capacity + (capacity shr 1))
        _arr = _arr.copyOf(newCapacity)
    }

    fun ensureCapacity(minCapacity: Int) { if(capacity < minCapacity) grow(minCapacity) }

    operator fun get(index: Int): Int {
        require(index in 0 until size)
        return _arr[index]
    }

    operator fun set(index: Int, value: Int) {
        require(index in 0 until size)
        _arr[index] = value
    }

    fun add(value: Int) {
        if(size == capacity) grow()
        _arr[size++] = value
    }

    fun addAll(list: IntList) {
        ensureCapacity(size + list.size)
        list._arr.copyInto(_arr, size, 0, list.size)
        size += list.size
    }

    fun add(index: Int, element: Int) {
        if(size == capacity) grow()
        _arr.copyInto(_arr, index + 1, index, size)
        size++
        set(index, element)
    }

    fun clear() { size = 0 }

    fun removeAt(index: Int): Int {
        val e = get(index)
        _arr.copyInto(_arr, index, index + 1, size)
        size--
        return e
    }

    fun indexOf(e: Int): Int {
        for(i in 0 until size) if(this[i] == e) return i
        return -1
    }

    fun remove(e: Int): Boolean {
        val i = indexOf(e)
        if(i == -1) return false
        removeAt(i)
        return true
    }

    operator fun iterator() = object: IntIterator() {
        private var pos = 0
        override fun hasNext() = pos < size
        override fun nextInt() = get(pos++)
    }

    inline fun isEmpty() = size == 0
    inline fun isNotEmpty() = size != 0

    fun pop() = _arr[--size]

    fun popToSize(s: Int) {
        require(s >= 0)
        if(s < size) size = s
    }

    fun swap(i: Int, j: Int) { val t = this[i]; this[i] = this[j]; this[j] = t }
    fun reverse() {
        for(i in 0 until size / 2) swap(i, lastIndex - i)
    }

    fun shuffle(rnd: Random = random) { for(i in lastIndex downTo 1) swap(i, rnd.nextInt(i+1)) }
    fun sort() { shuffle(); _arr._sort(0, size) }
    fun sortDescending() { sort(); reverse() }

    fun joinToString(separator: CharSequence) = if(size == 0) "" else let {
        buildString {
            append(it[0])
            for (i in 1 until size) {
                append(separator).append(it[i])
            }
        }
    }

    override fun toString() = "[" + joinToString(", ") + "]"

    fun toIntArray() = _arr.copyOf(size)
    fun toList() = List(size, ::get)

    inline fun first() = get(0)
    inline fun last() = get(lastIndex)
}

inline fun IntList(size: Int, init: (Int) -> Int) = IntList(size).apply {
    for(i in 0 until size) { add(init(i)) }
}
inline fun IntArray.toIntList() = IntList(this)
inline fun Collection<Int>.toIntList() = IntList(this)
inline fun intListOf(vararg values: Int) = IntList(values)

fun IntList.max() = (1 until size).fold(this[0]) { acc, i -> max(acc, this[i]) }
fun IntList.min() = (1 until size).fold(this[0]) { acc, i -> min(acc, this[i]) }
fun IntList.getOrNull(i: Int) = if(i in indices) get(i) else null
inline fun IntList.count(predicate: (Int) -> Boolean) = indices.count { predicate(this[it]) }
fun IntList.copyOf() = IntList(size, ::get)

/** IO */
//const val PATH = "src/main/resources/"
//@JvmField val INPUT = File(PATH + "input.txt").inputStream()
//@JvmField val OUTPUT = File(PATH + "output.txt").outputStream()
@JvmField val INPUT = System.`in`
@JvmField val OUTPUT = System.out

const val _BUFFER_SIZE = 1 shl 16
@JvmField val _buffer = ByteArray(_BUFFER_SIZE)
@JvmField var _bufferPt = 0
@JvmField var _bytesRead = 0

tailrec fun readChar(): Char {
    if(_bufferPt == _bytesRead) {
        _bufferPt = 0
        _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)
    }
    return if(_bytesRead < 0) Char.MIN_VALUE
    else {
        val c = _buffer[_bufferPt++].toChar()
        if (c == '\r') readChar()
        else c
    }
}

/** @param skipNext Whether to skip the next character (usually whitespace), defaults to true */
fun readCharArray(n: Int, skipNext: Boolean = true): CharArray {
    val res = CharArray(n) { readChar() }
    if(skipNext) readChar()
    return res
}

fun readLine(): String? {
    var c = readChar()
    return if(c == Char.MIN_VALUE) null
    else buildString {
        while(c != '\n' && c != Char.MIN_VALUE) {
            append(c)
            c = readChar()
        }
    }
}
fun readLn() = readLine()!!

fun read() = buildString {
    var c = readChar()
    while(c <= ' ') {
        if(c == Char.MIN_VALUE) return@buildString
        c = readChar()
    }
    do {
        append(c)
        c = readChar()
    } while(c > ' ')
}
fun readInt() = read().toInt()
fun readDouble() = read().toDouble()
fun readLong() = read().toLong()
fun readStrings(n: Int) = List(n) { read() }
fun readLines(n: Int) = List(n) { readLn() }
fun readInts(n: Int) = List(n) { read().toInt() }
fun readIntArray(n: Int) = IntArray(n) { read().toInt() }
fun readDoubles(n: Int) = List(n) { read().toDouble() }
fun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }
fun readLongs(n: Int) = List(n) { read().toLong() }
fun readLongArray(n: Int) = LongArray(n) { read().toLong() }

@JvmField val _writer = PrintWriter(OUTPUT, false)

/**  sort overrides to avoid quicksort attacks */

@JvmField var _random: Random? = null
val random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }

fun IntArray.sort() { shuffle(random); _sort() }
fun IntArray.sortDescending() { shuffle(random); _sortDescending() }

fun LongArray.sort() { shuffle(random); _sort() }
fun LongArray.sortDescending() { shuffle(random); _sortDescending() }

fun DoubleArray.sort() { shuffle(random); _sort() }
fun DoubleArray.sortDescending() { shuffle(random); _sortDescending() }

inline fun CharArray.sort() { _sort() }
inline fun CharArray.sortDescending() { _sortDescending() }

inline fun <T : Comparable<T>> Array<out T>.sort() = _sort()
inline fun <T : Comparable<T>> Array<out T>.sortDescending() = _sortDescending()
inline fun <T : Comparable<T>> MutableList<out T>.sort() = _sort()
inline fun <T : Comparable<T>> MutableList<out T>.sortDescending() = _sortDescending()

// import preserving junk function
@Suppress("NonAsciiCharacters") fun 雪花飄飄北風嘯嘯天地一片蒼茫() { iprintln(max(1, 2)) }

// max/min Kotlin 1.6 -> 1.4 shim
fun IntArray.max() = maxOf { it }
fun IntArray.min() = minOf { it }
fun LongArray.max() = maxOf { it }
fun LongArray.min() = minOf { it }
fun CharArray.max() = maxOf { it }
fun CharArray.min() = minOf { it }
fun <T: Comparable<T>> Iterable<T>.max() = maxOf { it }
fun <T: Comparable<T>> Iterable<T>.min() = minOf { it }
fun <T: Comparable<T>> Sequence<T>.max() = maxOf { it }
fun <T: Comparable<T>> Sequence<T>.min() = minOf { it }


@file:Suppress("NOTHING_TO_INLINE", "EXPERIMENTAL_FEATURE_WARNING", "OVERRIDE_BY_INLINE")
@file:OptIn(ExperimentalStdlibApi::class)

import java.io.PrintWriter
import kotlin.math.*
import kotlin.random.Random
import kotlin.collections.sort as _sort
import kotlin.collections.sortDescending as _sortDescending
import kotlin.io.println as iprintln

/** @author Spheniscine */
fun main() { _writer.solve(); _writer.flush() }
fun PrintWriter.solve() {
//    val startTime = System.nanoTime()

    val numCases = 1//readInt()
    case@ for(case in 1..numCases) {
//        print("Case #$case: ")

        val n = readInt()
        val m = readInt()
        val q = readInt()

        val U = IntArray(m)
        val V = IntArray(m) {
            U[it] = readInt()-1
            readInt()-1
        }

        val firstNo = IntArray(m)
        val dsu = BipartiteDSURollback(n)

        var l2 = m-1
        dsu.persist()
        for(i in 0 until m) {
            if(!dsu.join(U[i], V[i], OPP)) {
                for(j in i+1 until m) firstNo[j] = m
                l2 = i
                break
            }
        }
        dsu.rollback()

        fun rec(l1: Int, l2: Int, r1: Int, r2: Int) {
            if(l1 > l2) return
            val lm = (l1 + l2) / 2

            dsu.persist()

            for(i in l1 until lm) dsu.join(U[i], V[i], OPP)

            dsu.persist()

            var rm = r2
            val lim = max(lm, r1)
            while(rm > lim && dsu.join(U[rm], V[rm], OPP)) rm--
            firstNo[lm] = rm

            dsu.rollback()

            dsu.join(U[lm], V[lm], OPP)
            rec(lm+1, l2, rm, r2)

            dsu.rollback()

            for(i in rm+1..r2) dsu.join(U[i], V[i], OPP)
            rec(l1, lm-1, r1, rm)
        }

        rec(0, l2, 0, m-1)

        repeat(q) {
            val l = readInt()-1
            val r = readInt()-1

            val ans = r < firstNo[l]
            println(if(ans) "YES" else "NO")
        }
    }

//    iprintln("Time: ${(System.nanoTime() - startTime) / 1000000} ms")
}

const val SYN: Byte = 1
const val OPP: Byte = 2
const val NOR: Byte = 3

class BipartiteDSURollback(n: Int) {

    private val hist = IntList()
    private val sav = IntList()

    private val id = IntArray(n) { it }
    private val sz = IntArray(n) { 1 }
    private val opp = BooleanArray(n)

    fun relation(u: Int, v: Int): Byte {
        var p = false
        var ru = u
        while(id[ru] != ru) {
            p = p xor opp[ru]
            ru = id[ru]
        }
        var rv = v
        while(id[rv] != rv) {
            p = p xor opp[rv]
            rv = id[rv]
        }

        return when {
            ru != rv -> NOR
            p -> OPP
            else -> SYN
        }
    }

    fun join(u: Int, v: Int, r: Byte): Boolean {
        var p = r == OPP
        var ru = u
        while(id[ru] != ru) {
            p = p xor opp[ru]
            ru = id[ru]
        }
        var rv = v
        while(id[rv] != rv) {
            p = p xor opp[rv]
            rv = id[rv]
        }

        if(ru == rv) return !p

        if(sz[ru] < sz[rv]) ru = rv.also { rv = ru }

        hist.add(rv)

        id[rv] = ru
        sz[ru] += sz[rv]
        opp[rv] = p
        return true
    }

    tailrec fun root(v: Int): Int =
        if(id[v] == v) v else root(id[v])

    fun size(v: Int) = sz[root(v)]

    fun persist() { sav.add(hist.size) }

    fun rollback() {
        val s = sav.pop()

        while(hist.size > s) {
            val v = hist.pop()
            val u = id[v]

            id[v] = v
            sz[u] -= sz[v]
            opp[v] = false
        }
    }
}

class IntList(initialCapacity: Int = 12) {
    private var _arr = IntArray(initialCapacity)
    private val capacity get() = _arr.size
    var size = 0
        private set
    inline val lastIndex get() = size - 1
    inline val indices get() = 0 until size

    constructor(copyFrom: IntArray): this(copyFrom.size) { copyFrom.copyInto(_arr); size = copyFrom.size }
    constructor(copyFrom: Collection<Int>): this(copyFrom.size) { _arr = copyFrom.toIntArray(); size = copyFrom.size }

    fun contentEquals(other: IntList): Boolean {
        return this === other || size == other.size && indices.all { this[it] == other[it] }
    }

    private fun grow(minCapacity: Int = 8) {
        val newCapacity = maxOf(minCapacity, capacity + (capacity shr 1))
        _arr = _arr.copyOf(newCapacity)
    }

    fun ensureCapacity(minCapacity: Int) { if(capacity < minCapacity) grow(minCapacity) }

    operator fun get(index: Int): Int {
        require(index in 0 until size)
        return _arr[index]
    }

    operator fun set(index: Int, value: Int) {
        require(index in 0 until size)
        _arr[index] = value
    }

    fun add(value: Int) {
        if(size == capacity) grow()
        _arr[size++] = value
    }

    fun addAll(list: IntList) {
        ensureCapacity(size + list.size)
        list._arr.copyInto(_arr, size, 0, list.size)
        size += list.size
    }

    fun add(index: Int, element: Int) {
        if(size == capacity) grow()
        _arr.copyInto(_arr, index + 1, index, size)
        size++
        set(index, element)
    }

    fun clear() { size = 0 }

    fun removeAt(index: Int): Int {
        val e = get(index)
        _arr.copyInto(_arr, index, index + 1, size)
        size--
        return e
    }

    fun indexOf(e: Int): Int {
        for(i in 0 until size) if(this[i] == e) return i
        return -1
    }

    fun remove(e: Int): Boolean {
        val i = indexOf(e)
        if(i == -1) return false
        removeAt(i)
        return true
    }

    operator fun iterator() = object: IntIterator() {
        private var pos = 0
        override fun hasNext() = pos < size
        override fun nextInt() = get(pos++)
    }

    inline fun isEmpty() = size == 0
    inline fun isNotEmpty() = size != 0

    fun pop() = _arr[--size]

    fun popToSize(s: Int) {
        require(s >= 0)
        if(s < size) size = s
    }

    fun swap(i: Int, j: Int) { val t = this[i]; this[i] = this[j]; this[j] = t }
    fun reverse() {
        for(i in 0 until size / 2) swap(i, lastIndex - i)
    }

    fun shuffle(rnd: Random = random) { for(i in lastIndex downTo 1) swap(i, rnd.nextInt(i+1)) }
    fun sort() { shuffle(); _arr._sort(0, size) }
    fun sortDescending() { sort(); reverse() }

    fun joinToString(separator: CharSequence) = if(size == 0) "" else let {
        buildString {
            append(it[0])
            for (i in 1 until size) {
                append(separator).append(it[i])
            }
        }
    }

    override fun toString() = "[" + joinToString(", ") + "]"

    fun toIntArray() = _arr.copyOf(size)
    fun toList() = List(size, ::get)

    inline fun first() = get(0)
    inline fun last() = get(lastIndex)
}

inline fun IntList(size: Int, init: (Int) -> Int) = IntList(size).apply {
    for(i in 0 until size) { add(init(i)) }
}
inline fun IntArray.toIntList() = IntList(this)
inline fun Collection<Int>.toIntList() = IntList(this)
inline fun intListOf(vararg values: Int) = IntList(values)

fun IntList.max() = (1 until size).fold(this[0]) { acc, i -> max(acc, this[i]) }
fun IntList.min() = (1 until size).fold(this[0]) { acc, i -> min(acc, this[i]) }
fun IntList.getOrNull(i: Int) = if(i in indices) get(i) else null
inline fun IntList.count(predicate: (Int) -> Boolean) = indices.count { predicate(this[it]) }
fun IntList.copyOf() = IntList(size, ::get)

/** IO */
//const val PATH = "src/main/resources/"
//@JvmField val INPUT = File(PATH + "input.txt").inputStream()
//@JvmField val OUTPUT = File(PATH + "output.txt").outputStream()
@JvmField val INPUT = System.`in`
@JvmField val OUTPUT = System.out

const val _BUFFER_SIZE = 1 shl 16
@JvmField val _buffer = ByteArray(_BUFFER_SIZE)
@JvmField var _bufferPt = 0
@JvmField var _bytesRead = 0

tailrec fun readChar(): Char {
    if(_bufferPt == _bytesRead) {
        _bufferPt = 0
        _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)
    }
    return if(_bytesRead < 0) Char.MIN_VALUE
    else {
        val c = _buffer[_bufferPt++].toChar()
        if (c == '\r') readChar()
        else c
    }
}

/** @param skipNext Whether to skip the next character (usually whitespace), defaults to true */
fun readCharArray(n: Int, skipNext: Boolean = true): CharArray {
    val res = CharArray(n) { readChar() }
    if(skipNext) readChar()
    return res
}

fun readLine(): String? {
    var c = readChar()
    return if(c == Char.MIN_VALUE) null
    else buildString {
        while(c != '\n' && c != Char.MIN_VALUE) {
            append(c)
            c = readChar()
        }
    }
}
fun readLn() = readLine()!!

fun read() = buildString {
    var c = readChar()
    while(c <= ' ') {
        if(c == Char.MIN_VALUE) return@buildString
        c = readChar()
    }
    do {
        append(c)
        c = readChar()
    } while(c > ' ')
}
fun readInt() = read().toInt()
fun readDouble() = read().toDouble()
fun readLong() = read().toLong()
fun readStrings(n: Int) = List(n) { read() }
fun readLines(n: Int) = List(n) { readLn() }
fun readInts(n: Int) = List(n) { read().toInt() }
fun readIntArray(n: Int) = IntArray(n) { read().toInt() }
fun readDoubles(n: Int) = List(n) { read().toDouble() }
fun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }
fun readLongs(n: Int) = List(n) { read().toLong() }
fun readLongArray(n: Int) = LongArray(n) { read().toLong() }

@JvmField val _writer = PrintWriter(OUTPUT, false)

/**  sort overrides to avoid quicksort attacks */

@JvmField var _random: Random? = null
val random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }

fun IntArray.sort() { shuffle(random); _sort() }
fun IntArray.sortDescending() { shuffle(random); _sortDescending() }

fun LongArray.sort() { shuffle(random); _sort() }
fun LongArray.sortDescending() { shuffle(random); _sortDescending() }

fun DoubleArray.sort() { shuffle(random); _sort() }
fun DoubleArray.sortDescending() { shuffle(random); _sortDescending() }

inline fun CharArray.sort() { _sort() }
inline fun CharArray.sortDescending() { _sortDescending() }

inline fun <T : Comparable<T>> Array<out T>.sort() = _sort()
inline fun <T : Comparable<T>> Array<out T>.sortDescending() = _sortDescending()
inline fun <T : Comparable<T>> MutableList<out T>.sort() = _sort()
inline fun <T : Comparable<T>> MutableList<out T>.sortDescending() = _sortDescending()

// import preserving junk function
@Suppress("NonAsciiCharacters") fun 雪花飄飄北風嘯嘯天地一片蒼茫() { iprintln(max(1, 2)) }

// max/min Kotlin 1.6 -> 1.4 shim
fun IntArray.max() = maxOf { it }
fun IntArray.min() = minOf { it }
fun LongArray.max() = maxOf { it }
fun LongArray.min() = minOf { it }
fun CharArray.max() = maxOf { it }
fun CharArray.min() = minOf { it }
fun <T: Comparable<T>> Iterable<T>.max() = maxOf { it }
fun <T: Comparable<T>> Iterable<T>.min() = minOf { it }
fun <T: Comparable<T>> Sequence<T>.max() = maxOf { it }
fun <T: Comparable<T>> Sequence<T>.min() = minOf { it }