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

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

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

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

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

n.r = b
n.u = l
n.w = d
l.z = b
l.y = h
h.t = n
e.q = d
b.r = n
b.u = k
b.w = e
g.t = b
d.q = e
a.z = n
a.y = g
k.z = n
k.y = g
assert d.q.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.u: B = None
        self.w: D = None
        self.txt = txt

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

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

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

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

n.r = b
n.u = l
n.w = d
l.z = b
l.y = h
h.t = n
e.q = d
b.r = n
b.u = k
b.w = e
g.t = b
d.q = e
a.z = n
a.y = g
k.z = n
k.y = g
assert d.q.q.q.q.q.txt == "e"