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

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

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

k = A("k")
m = B("m")
a = C("a")
g = B("g")
i = A("i")
c = B("c")

k.w = m
k.r = m
k.o = i
m.w = a
a.y = c
g.w = a
i.w = g
i.o = k
i.r = c
c.w = a
assert k.o.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.o: A = None
        self.r: B = None
        self.txt = txt

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

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

k = A("k")
m = B("m")
a = C("a")
g = B("g")
i = A("i")
c = B("c")

k.w = m
k.r = m
k.o = i
m.w = a
a.y = c
g.w = a
i.w = g
i.o = k
i.r = c
c.w = a
assert k.o.r.w.txt == "a"