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

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

j = A("j")
f = B("f")
d = A("d")
e = B("e")
n = B("n")
g = A("g")
b = B("b")

j.q = d
j.u = g
f.t = j
d.q = g
d.u = g
e.t = d
n.t = g
g.q = d
g.u = d
b.t = j
assert j.u.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.u: A = None
        self.txt = txt

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

j = A("j")
f = B("f")
d = A("d")
e = B("e")
n = B("n")
g = A("g")
b = B("b")

j.q = d
j.u = g
f.t = j
d.q = g
d.u = g
e.t = d
n.t = g
g.q = d
g.u = d
b.t = j
assert j.u.u.q.txt == "g"