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

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

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

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

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

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

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

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

n.z = i
l.u = i
l.x = n
l.w = k
g.z = k
j.z = l
k.u = n
k.x = i
k.w = l
i.z = n
assert g.z.u.z.txt == "i"