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

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

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

k = A("k")
d = B("d")
c = C("c")
i = B("i")
b = A("b")
g = C("g")

k.w = b
k.z = b
d.u = i
d.t = c
d.r = b
c.o = b
c.t = g
i.u = d
i.t = g
i.r = b
b.w = k
b.z = k
g.o = k
g.t = c
assert g.o.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.z: A = None
        self.txt = txt

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

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

k = A("k")
d = B("d")
c = C("c")
i = B("i")
b = A("b")
g = C("g")

k.w = b
k.z = b
d.u = i
d.t = c
d.r = b
c.o = b
c.t = g
i.u = d
i.t = g
i.r = b
b.w = k
b.z = k
g.o = k
g.t = c
assert g.o.z.z.txt == "k"