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

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

i = A("i")
l = B("l")
g = B("g")
j = B("j")
c = A("c")
e = B("e")
f = B("f")
a = A("a")

i.t = l
l.q = g
g.q = e
j.q = e
c.t = e
e.q = j
f.q = j
a.t = j
assert a.t.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

i = A("i")
l = B("l")
g = B("g")
j = B("j")
c = A("c")
e = B("e")
f = B("f")
a = A("a")

i.t = l
l.q = g
g.q = e
j.q = e
c.t = e
e.q = j
f.q = j
a.t = j
assert a.t.q.q.q.q.txt == "j"