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

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

b = A("b")
f = B("f")
d = A("d")
k = B("k")
j = B("j")
c = A("c")
e = B("e")
i = A("i")
l = A("l")
a = B("a")

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

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

b = A("b")
f = B("f")
d = A("d")
k = B("k")
j = B("j")
c = A("c")
e = B("e")
i = A("i")
l = A("l")
a = B("a")

b.t = j
f.v = j
f.q = b
d.t = e
k.v = e
k.q = i
j.v = e
j.q = l
c.t = f
e.v = f
e.q = l
i.t = k
l.t = e
a.v = e
a.q = i
assert e.v.v.q.t.q.txt == "l"