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

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

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

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

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

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

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

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

n.x = i
i.p = n
i.t = e
i.y = c
b.y = n
b.w = n
m.y = n
m.w = n
e.p = n
e.t = i
e.y = c
c.p = n
c.t = e
c.y = e
assert m.w.x.y.txt == "c"