extern crate core;

use std::fmt;
use std::cmp::{Ordering, min, max};
use std::fmt::{Display, Error, Formatter};
use std::f32::MAX;
use std::ops::{Add, Sub, Mul, Div, Neg, Index, IndexMut};
use std::collections::{BTreeMap, VecDeque};

fn show<T: Display>(vec: &Vec<T>) {
    if vec.is_empty() {
        println!("[]");
    }else {
        print!("[{}", vec[0]);
        for i in 1 .. vec.len() {
            print!(", {}", vec[i]);
        }
        println!("]");
    }
}
fn show2<T: Display>(vec: &Vec<Vec<T>>) {
    if vec.is_empty() {
        println!("[]");
    }else {
        for l in vec {
            show(l);
        }
    }
}
macro_rules! read_line{
    () => {{
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).ok();
        line
    }};
    (delimiter: ' ') => {
        read_line!().split_whitespace().map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (delimiter: $p:expr) => {
        read_line!().split($p).map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (' ') => {
        read_line!(delimiter: ' ')
    };
    ($delimiter:expr) => {
        read_line!(delimiter: $delimiter)
    };
    (' '; $ty:ty) => {
        read_line!().split_whitespace().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
    ($delimiter:expr; $ty:ty) => {
        read_line!($delimiter).into_iter().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
}
macro_rules! read_value{
    () => {
        read_line!().trim().parse().ok().unwrap()
    }
}
macro_rules! let_all {
    ($($n:ident:$t:ty),*) => {
        let line = read_line!(delimiter: ' ');
        let mut iter = line.iter();
        $(let $n:$t = iter.next().unwrap().parse().ok().unwrap();)*
    };
}
macro_rules! let_mut_all {
    ($($n:ident:$t:ty),*) => {
        let line = read_line!(delimiter: ' ');
        let mut iter = line.iter();
        $(let mut $n:$t = iter.next().unwrap().parse().ok().unwrap();)*
    };
}
fn set_depth(nodes: &Vec<Vec<i32>>, memo: &mut Vec<i32>) {
    for i in 1 .. memo.len() {
        memo[i] = -1;
    }
    memo[0] = 0;
    let mut queue = VecDeque::new();
    queue.push_back(0);
    while let Some(c) = queue.pop_front() {
        if c != nodes.len() - 1 {
            for next in 0..nodes[c].len() {
                if nodes[c][next] > 0 && memo[next] == -1 {
                    memo[next] = memo[c] + 1;
                    queue.push_back(next);
                }
            }
        }else {
            break
        }
    }
}
fn push_flow(current: usize, nodes: &mut Vec<Vec<i32>>, searching: &mut Vec<usize>, depth: &Vec<i32>, min_flow: i32) -> i32 {
    if current == nodes.len() - 1 {
        min_flow
    }else {
        while searching[current] < nodes[current].len() {
            if nodes[current][searching[current]] > 0 && depth[searching[current]] != - 1 && depth[searching[current]] > depth[current] {
                let next = searching[current];
                let min_flow = min(min_flow, nodes[current][next]);
                let flow = push_flow(next,  nodes, searching, depth, min_flow);
                if flow > 0 {
                    nodes[current][next] -= flow;
                    nodes[next][current] += flow;
                    return flow;
                }
            }
            searching[current] += 1;
        }
        0
    }
}
fn set_max_flow(nodes: &mut Vec<Vec<i32>>) -> i32 {
    let mut depth = vec![-1; nodes.len()];
    let mut searching = vec![0; nodes.len()];
    let mut has_flow = true;
    let mut flow = 0;
    while has_flow {
        has_flow = false;
        set_depth(nodes, &mut depth);
        for i in 0 .. searching.len() {
            searching[i] = 0;
        }
        loop {
            let f = push_flow(0, nodes, &mut searching, &depth, std::i32::MAX);
            if f > 0 {
                flow += f;
                has_flow = true;
            }else {
                break
            }
        }
    }
    flow
}
fn remove_to_goal(current: usize, nodes: &mut Vec<Vec<i32>>) {
    if current != nodes.len() - 1 {
        for next in 0..nodes.len() {
            if nodes[next][current] == 2 {
                nodes[current][next] = 1;
                nodes[next][current] = 1;
                return remove_to_goal(next, nodes)
            }
        }
    }
}
fn remove_from_start(current: usize, nodes: &mut Vec<Vec<i32>>) {
    if current != 0 {
        for next in 0 .. nodes.len() {
            if nodes[current][next] == 2 {
                nodes[current][next] = 1;
                nodes[next][current] = 1;
                return remove_from_start(next, nodes);
            }
        }
    }
}
fn depth_first_search(current: usize, nodes: &mut Vec<Vec<i32>>, memo: &mut Vec<bool>) -> bool {
    if current == nodes.len() - 1 {
        true
    }else {
        memo[current] = true;
        for next in 0 .. nodes.len() {
            if !memo[next] && nodes[current][next] > 0 && depth_first_search(next, nodes, memo) {
                nodes[current][next] -= 1;
                nodes[next][current] += 1;
                return true
            }
        }
        false
    }
}
fn push_single(nodes: &mut Vec<Vec<i32>>) -> i32 {
    let mut memo = vec![false; nodes.len()];
    if depth_first_search(0, nodes, &mut memo) {
        1
    }else {
        0
    }
}
fn remove_flow(nodes: &mut Vec<Vec<i32>>, end_a: usize, end_b: usize) -> i32 {
    if nodes[end_a][end_b] == 1 && nodes[end_b][end_a] == 1 {
        nodes[end_a][end_b] = 0;
        nodes[end_b][end_a] = 0;
        0
    }else {
        if nodes[end_a][end_b] == 2 {
            nodes[end_a][end_b] = 0;
            nodes[end_b][end_a] = 0;
            remove_to_goal(end_a, nodes);
            remove_from_start(end_b, nodes);
            push_single(nodes) - 1
        }else {
            nodes[end_a][end_b] = 0;
            nodes[end_b][end_a] = 0;
            remove_to_goal(end_b, nodes);
            remove_from_start(end_a, nodes);
            push_single(nodes) - 1
        }
    }
}
fn add_flow(nodes: &mut Vec<Vec<i32>>, end_a: usize, end_b: usize) -> i32 {
    nodes[end_a][end_b] = 1;
    nodes[end_b][end_a] = 1;
    push_single(nodes)
}
fn main() {
    let_all!(n: usize, e: usize, q: usize);
    let mut network = vec![vec![0; n]; n];
    for _ in 0 .. e {
        let_all!(f: usize, t: usize);
        network[f - 1][t - 1] = 1;
        network[t - 1][f - 1] = 1;
    }
    let mut flow = set_max_flow(&mut network);
    for i in 0 .. q {
        let_all!(m: usize, a: usize, b: usize);
        match m {
            1 => {
                add_flow(&mut network, a - 1, b - 1)
            }
            2 => {
                remove_flow(&mut network, a - 1, b - 1)
            }
            _ => unreachable!()
        };
        flow = 0;
        for i in 0 .. network.len() {
            if network[n - 1][i] == 2 {
                flow += 1;
            }
        }
        println!("{}", flow);
    }
}


Measured memory_bytes: 5084