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

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

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

k = A("k")
e = B("e")
m = C("m")
n = B("n")
c = A("c")
b = C("b")

k.x = e
k.w = n
k.o = c
e.p = m
e.y = c
m.r = b
m.o = b
m.p = e
n.p = m
n.y = c
c.x = e
c.w = e
c.o = k
b.r = m
b.o = m
b.p = e
assert e.p.o.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.w: B = None
        self.o: A = None
        self.txt = txt

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

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

k = A("k")
e = B("e")
m = C("m")
n = B("n")
c = A("c")
b = C("b")

k.x = e
k.w = n
k.o = c
e.p = m
e.y = c
m.r = b
m.o = b
m.p = e
n.p = m
n.y = c
c.x = e
c.w = e
c.o = k
b.r = m
b.o = m
b.p = e
assert e.p.o.p.p.txt == "m"