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

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

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

n = A("n")
i = B("i")
h = C("h")
l = A("l")
g = A("g")
k = A("k")

n.z = h
i.x = n
h.u = i
h.y = i
l.z = h
g.z = h
k.z = h
assert k.z.y.x.z.y.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

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

n = A("n")
i = B("i")
h = C("h")
l = A("l")
g = A("g")
k = A("k")

n.z = h
i.x = n
h.u = i
h.y = i
l.z = h
g.z = h
k.z = h
assert k.z.y.x.z.y.txt == "i"