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

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

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

k = A("k")
e = B("e")
a = C("a")
g = B("g")
b = C("b")

k.x = b
e.o = g
e.w = g
e.r = g
a.x = e
a.t = g
a.u = k
g.o = e
g.w = e
g.r = e
b.x = g
b.t = g
b.u = k
assert a.t.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

k = A("k")
e = B("e")
a = C("a")
g = B("g")
b = C("b")

k.x = b
e.o = g
e.w = g
e.r = g
a.x = e
a.t = g
a.u = k
g.o = e
g.w = e
g.r = e
b.x = g
b.t = g
b.u = k
assert a.t.o.r.txt == "g"