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

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

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

k = A("k")
g = B("g")
l = C("l")
b = B("b")
n = C("n")
i = A("i")
j = B("j")
a = C("a")

k.x = b
k.r = i
g.t = i
g.x = i
g.u = b
l.z = a
b.t = k
b.x = k
b.u = j
n.z = l
i.x = g
i.r = k
j.t = k
j.u = g
j.x = i
a.z = n
assert l.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.r: A = None
        self.txt = txt

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

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

k = A("k")
g = B("g")
l = C("l")
b = B("b")
n = C("n")
i = A("i")
j = B("j")
a = C("a")

k.x = b
k.r = i
g.t = i
g.x = i
g.u = b
l.z = a
b.t = k
b.x = k
b.u = j
n.z = l
i.x = g
i.r = k
j.t = k
j.u = g
j.x = i
a.z = n
assert l.z.z.z.z.txt == "a"