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

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

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

j = A("j")
c = B("c")
i = C("i")

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

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

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

j = A("j")
c = B("c")
i = C("i")

j.y = i
j.w = i
j.r = c
c.u = i
c.w = j
c.o = j
i.z = c
assert i.z.u.z.txt == "c"