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

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

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

m = A("m")
i = B("i")
f = C("f")
n = B("n")
l = C("l")

m.o = n
m.w = f
m.p = i
i.y = n
f.o = i
f.p = i
f.y = m
n.y = i
l.o = i
l.p = i
l.y = m
assert f.p.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.w: C = None
        self.p: B = None
        self.txt = txt

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

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

m = A("m")
i = B("i")
f = C("f")
n = B("n")
l = C("l")

m.o = n
m.w = f
m.p = i
i.y = n
f.o = i
f.p = i
f.y = m
n.y = i
l.o = i
l.p = i
l.y = m
assert f.p.y.y.txt == "i"