class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.q: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

g = A("g")
c = B("c")
n = A("n")
j = B("j")
b = A("b")
m = B("m")
f = B("f")
h = B("h")

g.u = b
g.q = b
c.v = b
n.u = b
n.q = b
j.v = g
b.u = g
b.q = n
m.v = g
f.v = b
h.v = b
assert h.v.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.q: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

g = A("g")
c = B("c")
n = A("n")
j = B("j")
b = A("b")
m = B("m")
f = B("f")
h = B("h")

g.u = b
g.q = b
c.v = b
n.u = b
n.q = b
j.v = g
b.u = g
b.q = n
m.v = g
f.v = b
h.v = b
assert h.v.q.q.q.txt == "n"