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

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

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

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

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

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

h.q = n
h.w = e
d.s = n
d.r = j
k.w = e
b.v = h
j.q = n
j.w = d
j.y = h
e.v = h
n.s = d
n.r = j
assert h.q.r.w.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.w: D = None
        self.txt = txt

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

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

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

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

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

h.q = n
h.w = e
d.s = n
d.r = j
k.w = e
b.v = h
j.q = n
j.w = d
j.y = h
e.v = h
n.s = d
n.r = j
assert h.q.r.w.r.q.txt == "n"