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

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

class C:
    def __init__(self, txt: str):
        self.q: B = None
        self.r: B = None
        self.txt = txt

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

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

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

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

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

class C:
    def __init__(self, txt: str):
        self.q: B = None
        self.r: B = None
        self.txt = txt

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

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

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

d.z = l
d.x = l
l.v = g
l.r = h
h.q = l
h.r = l
g.o = h
g.y = h
g.p = l
g.r = l
g.w = j
j.o = l
assert l.v.o.r.v.txt == "g"