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

class B:
    def __init__(self, txt: str):
        self.s: D = None
        self.z: C = None
        self.q: B = None
        self.p: B = None
        self.txt = txt

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

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

e = A("e")
h = B("h")
d = C("d")
l = D("l")
b = B("b")
n = D("n")

e.u = d
h.s = n
h.z = d
h.q = b
h.p = b
d.u = n
d.z = l
d.v = h
l.v = n
b.s = n
b.z = d
b.q = h
b.p = h
n.v = l
assert b.z.u.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: D = None
        self.z: C = None
        self.q: B = None
        self.p: B = None
        self.txt = txt

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

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

e = A("e")
h = B("h")
d = C("d")
l = D("l")
b = B("b")
n = D("n")

e.u = d
h.s = n
h.z = d
h.q = b
h.p = b
d.u = n
d.z = l
d.v = h
l.v = n
b.s = n
b.z = d
b.q = h
b.p = h
n.v = l
assert b.z.u.v.v.v.v.txt == "n"