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

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

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

g = A("g")
a = B("a")
c = C("c")
n = C("n")

g.u = a
a.w = n
a.z = n
a.r = g
c.o = a
c.z = g
c.t = g
n.o = a
n.z = g
n.t = g
assert n.z.u.r.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

g = A("g")
a = B("a")
c = C("c")
n = C("n")

g.u = a
a.w = n
a.z = n
a.r = g
c.o = a
c.z = g
c.t = g
n.o = a
n.z = g
n.t = g
assert n.z.u.r.txt == "g"