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

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

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

a = A("a")
i = B("i")
n = C("n")
j = C("j")

a.w = i
a.x = i
a.u = i
i.y = n
i.u = a
n.z = j
n.r = i
n.y = i
j.z = n
j.r = i
j.y = i
assert a.u.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.x: B = None
        self.u: B = None
        self.txt = txt

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

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

a = A("a")
i = B("i")
n = C("n")
j = C("j")

a.w = i
a.x = i
a.u = i
i.y = n
i.u = a
n.z = j
n.r = i
n.y = i
j.z = n
j.r = i
j.y = i
assert a.u.y.y.txt == "i"