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

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

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

c = A("c")
d = B("d")
i = C("i")
a = A("a")
b = C("b")
h = C("h")
m = B("m")

c.w = i
d.p = m
i.x = d
i.u = d
a.w = h
b.x = m
b.u = m
h.x = d
h.u = m
m.p = d
assert d.p.p.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

c = A("c")
d = B("d")
i = C("i")
a = A("a")
b = C("b")
h = C("h")
m = B("m")

c.w = i
d.p = m
i.x = d
i.u = d
a.w = h
b.x = m
b.u = m
h.x = d
h.u = m
m.p = d
assert d.p.p.p.p.p.p.txt == "d"