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

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

b = A("b")
i = B("i")
e = B("e")
h = A("h")
l = B("l")
f = A("f")
a = A("a")
c = A("c")

b.z = l
b.x = e
i.q = e
e.q = l
h.z = l
h.x = i
l.q = i
f.z = i
f.x = e
a.z = l
a.x = e
c.z = i
c.x = i
assert i.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.x: B = None
        self.txt = txt

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

b = A("b")
i = B("i")
e = B("e")
h = A("h")
l = B("l")
f = A("f")
a = A("a")
c = A("c")

b.z = l
b.x = e
i.q = e
e.q = l
h.z = l
h.x = i
l.q = i
f.z = i
f.x = e
a.z = l
a.x = e
c.z = i
c.x = i
assert i.q.q.q.txt == "i"