#include <bits/stdc++.h>
#include "testlib.h"
 
using namespace std;
 
int main(int argc, char *argv[]) {
    registerValidation(argc, argv);
 

    int n = inf.readInt(2, 100'000, "n");
    inf.readEoln();
   
    map<int, set<int>> gr;

    set<pair<int, int>> edges;
    for (int i = 0; i < n-1; i++) {
        int u = inf.readInt(1, n, "u");
        inf.readSpace();
        int v = inf.readInt(1, n, "v");
        inf.readEoln();
        ensuref(u != v, "Loop!");

        ensuref(edges.count({u, v}) == 0, "Duplicated edge!");
        edges.insert({u, v});
        edges.insert({v, u});
        gr[u].insert(v);
        gr[v].insert(u);
    }
    int q = inf.readInt(1, 100'000, "q");
    set<int> av_ver;
    for (int i = 0; i < n; i++)
    {
        av_ver.insert(i+1);
    }
    inf.readEoln();
    int id = n+1;
    while(q--){
        char c = inf.readChar();
        inf.readSpace();
        int v = inf.readInteger(1, id, "v");
        inf.readEoln();
        ensuref(av_ver.count(v) == 1, "Not available ver");
        if(c == '+'){
            gr[v].insert(id);
            gr[id].insert(v);
            av_ver.insert(id++);

        }else{
            ensuref(gr[v].size() == 1, "Not leaf");
            auto it = *gr[v].begin();
            gr[v].erase(it);
            gr[it].erase(v);
            av_ver.erase(v);
        }
    }
    inf.readEof();
}
