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

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

h = A("h")
k = B("k")
c = B("c")
b = A("b")
g = B("g")
l = A("l")
a = A("a")
j = A("j")

h.q = b
h.z = c
k.z = c
c.z = k
b.q = l
b.z = g
g.z = c
l.q = h
l.z = c
a.q = h
a.z = c
j.q = b
j.z = c
assert a.z.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.z: B = None
        self.txt = txt

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

h = A("h")
k = B("k")
c = B("c")
b = A("b")
g = B("g")
l = A("l")
a = A("a")
j = A("j")

h.q = b
h.z = c
k.z = c
c.z = k
b.q = l
b.z = g
g.z = c
l.q = h
l.z = c
a.q = h
a.z = c
j.q = b
j.z = c
assert a.z.z.z.z.z.txt == "c"