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

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

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

k = A("k")
c = B("c")
h = C("h")
f = C("f")

k.t = h
k.r = f
c.o = f
c.u = k
h.z = c
h.x = f
f.z = c
f.x = h
assert c.u.r.x.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.r: C = None
        self.txt = txt

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

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

k = A("k")
c = B("c")
h = C("h")
f = C("f")

k.t = h
k.r = f
c.o = f
c.u = k
h.z = c
h.x = f
f.z = c
f.x = h
assert c.u.r.x.txt == "h"