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

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

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

class D:
    def __init__(self, txt: str):
        self.t: B = None
        self.s: C = None
        self.x: A = None
        self.v: A = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.r: C = None
        self.z: E = None
        self.y: E = None
        self.p: C = None
        self.v: C = None
        self.txt = txt

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

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

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

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

class D:
    def __init__(self, txt: str):
        self.t: B = None
        self.s: C = None
        self.x: A = None
        self.v: A = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.r: C = None
        self.z: E = None
        self.y: E = None
        self.p: C = None
        self.v: C = None
        self.txt = txt

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

d.t = n
d.x = n
a.w = d
a.p = d
a.s = f
n.z = d
n.p = d
n.o = a
n.r = a
n.w = i
i.t = a
i.s = n
i.x = d
i.v = d
f.r = n
f.p = n
f.v = n
f.z = h
f.y = h
h.r = n
h.p = n
h.v = n
h.z = f
h.y = f
assert h.y.y.p.w.txt == "i"