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

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

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

m = A("m")
c = B("c")
k = C("k")
j = A("j")
h = B("h")
e = C("e")

m.x = c
c.o = k
c.s = h
c.y = j
k.y = m
k.p = m
k.x = j
j.x = c
h.o = e
h.s = c
h.y = m
e.y = m
e.x = m
e.p = m
assert m.x.o.p.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

m = A("m")
c = B("c")
k = C("k")
j = A("j")
h = B("h")
e = C("e")

m.x = c
c.o = k
c.s = h
c.y = j
k.y = m
k.p = m
k.x = j
j.x = c
h.o = e
h.s = c
h.y = m
e.y = m
e.x = m
e.p = m
assert m.x.o.p.txt == "m"