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

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

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

j = A("j")
i = B("i")
e = C("e")
g = B("g")

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

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

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

j = A("j")
i = B("i")
e = C("e")
g = B("g")

j.r = e
j.w = g
j.x = i
i.u = g
i.w = e
i.z = e
e.t = j
e.o = i
g.u = i
g.w = e
g.z = e
assert e.o.w.o.txt == "i"