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

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

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

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

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

d = A("d")
j = B("j")
n = C("n")
i = D("i")
e = E("e")
c = E("c")
k = A("k")
b = D("b")
f = D("f")
h = E("h")

d.w = k
d.v = i
j.w = d
j.u = b
j.z = k
j.x = i
n.r = d
n.p = h
i.w = j
i.p = b
e.r = n
e.u = n
e.x = c
c.r = n
c.u = n
c.x = h
k.w = d
k.v = i
b.w = j
b.p = i
f.w = j
f.p = i
h.r = n
h.u = n
h.x = e
assert i.p.p.p.w.x.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.v: D = None
        self.txt = txt

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

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

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

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

d = A("d")
j = B("j")
n = C("n")
i = D("i")
e = E("e")
c = E("c")
k = A("k")
b = D("b")
f = D("f")
h = E("h")

d.w = k
d.v = i
j.w = d
j.u = b
j.z = k
j.x = i
n.r = d
n.p = h
i.w = j
i.p = b
e.r = n
e.u = n
e.x = c
c.r = n
c.u = n
c.x = h
k.w = d
k.v = i
b.w = j
b.p = i
f.w = j
f.p = i
h.r = n
h.u = n
h.x = e
assert i.p.p.p.w.x.txt == "i"