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

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

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

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

l.s = g
l.y = g
l.z = k
n.t = l
k.r = l
a.t = l
g.t = l
assert g.t.z.r.z.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.z: C = None
        self.y: B = None
        self.txt = txt

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

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

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

l.s = g
l.y = g
l.z = k
n.t = l
k.r = l
a.t = l
g.t = l
assert g.t.z.r.z.txt == "k"