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

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

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

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

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

n.q = h
n.u = i
e.t = i
e.w = d
c.o = i
h.z = d
h.q = d
h.r = e
j.z = d
j.q = c
j.r = e
d.o = i
i.q = j
i.u = n
assert c.o.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.u: A = None
        self.txt = txt

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

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

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

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

n.q = h
n.u = i
e.t = i
e.w = d
c.o = i
h.z = d
h.q = d
h.r = e
j.z = d
j.q = c
j.r = e
d.o = i
i.q = j
i.u = n
assert c.o.u.q.txt == "h"