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

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

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

c = A("c")
j = B("j")
e = C("e")
g = C("g")
k = B("k")
b = C("b")
n = A("n")
l = C("l")

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

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

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

c = A("c")
j = B("j")
e = C("e")
g = C("g")
k = B("k")
b = C("b")
n = A("n")
l = C("l")

c.q = n
j.r = k
j.z = c
e.q = g
g.q = l
k.r = j
k.z = n
b.q = g
n.q = c
l.q = b
assert e.q.q.q.q.q.q.q.q.txt == "l"