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

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

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

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

class E:
    def __init__(self, txt: str):
        self.s: C = None
        self.p: C = None
        self.w: A = None
        self.t: E = None
        self.z: B = None
        self.txt = txt

i = A("i")
b = B("b")
m = C("m")
d = D("d")
h = E("h")
a = E("a")
f = D("f")

i.p = m
b.y = i
b.t = i
m.x = i
d.p = i
d.w = f
h.s = m
h.p = m
h.w = i
h.t = a
h.z = b
a.s = m
a.p = m
a.w = i
a.t = h
a.z = b
f.p = i
f.w = d
assert a.w.p.x.p.x.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.s: C = None
        self.p: C = None
        self.w: A = None
        self.t: E = None
        self.z: B = None
        self.txt = txt

i = A("i")
b = B("b")
m = C("m")
d = D("d")
h = E("h")
a = E("a")
f = D("f")

i.p = m
b.y = i
b.t = i
m.x = i
d.p = i
d.w = f
h.s = m
h.p = m
h.w = i
h.t = a
h.z = b
a.s = m
a.p = m
a.w = i
a.t = h
a.z = b
f.p = i
f.w = d
assert a.w.p.x.p.x.txt == "i"