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

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

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

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

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

j.z = h
d.u = e
d.q = j
k.r = d
n.r = d
n.v = d
n.t = h
n.u = h
i.z = d
h.u = e
h.q = j
e.r = d
assert d.q.z.q.z.u.r.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

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

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

j.z = h
d.u = e
d.q = j
k.r = d
n.r = d
n.v = d
n.t = h
n.u = h
i.z = d
h.u = e
h.q = j
e.r = d
assert d.q.z.q.z.u.r.txt == "d"