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

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

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

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

class E:
    def __init__(self, txt: str):
        self.x: D = None
        self.txt = txt

h = A("h")
b = B("b")
i = C("i")
g = D("g")
j = E("j")
d = B("d")

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

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

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

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

class E:
    def __init__(self, txt: str):
        self.x: D = None
        self.txt = txt

h = A("h")
b = B("b")
i = C("i")
g = D("g")
j = E("j")
d = B("d")

h.w = i
b.p = h
b.z = d
b.v = g
i.y = h
i.t = g
g.w = i
g.r = i
g.y = b
g.o = d
j.x = g
d.p = h
d.z = b
d.v = g
assert j.x.y.v.w.y.txt == "h"