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

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

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

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

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

h = A("h")
d = B("d")
a = C("a")
n = D("n")
i = E("i")
j = D("j")
g = B("g")
m = C("m")

h.w = n
h.v = g
h.t = a
d.r = j
a.v = i
n.q = g
n.w = g
i.z = j
i.w = j
j.q = d
j.w = g
g.r = n
m.v = i
assert j.q.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.v: B = None
        self.t: C = None
        self.txt = txt

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

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

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

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

h = A("h")
d = B("d")
a = C("a")
n = D("n")
i = E("i")
j = D("j")
g = B("g")
m = C("m")

h.w = n
h.v = g
h.t = a
d.r = j
a.v = i
n.q = g
n.w = g
i.z = j
i.w = j
j.q = d
j.w = g
g.r = n
m.v = i
assert j.q.r.q.txt == "d"