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

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

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

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

h = A("h")
i = B("i")
a = C("a")
f = D("f")
g = B("g")
b = D("b")
e = D("e")
n = B("n")

h.q = a
i.z = h
i.o = h
i.y = g
i.r = g
a.u = g
f.y = h
f.q = h
f.v = a
f.x = a
g.z = h
g.o = h
g.y = n
g.r = n
b.y = h
b.q = h
b.v = a
b.x = a
e.y = h
e.q = h
e.v = a
e.x = a
n.z = h
n.o = h
n.y = g
n.r = g
assert n.z.q.u.o.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

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

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

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

h = A("h")
i = B("i")
a = C("a")
f = D("f")
g = B("g")
b = D("b")
e = D("e")
n = B("n")

h.q = a
i.z = h
i.o = h
i.y = g
i.r = g
a.u = g
f.y = h
f.q = h
f.v = a
f.x = a
g.z = h
g.o = h
g.y = n
g.r = n
b.y = h
b.q = h
b.v = a
b.x = a
e.y = h
e.q = h
e.v = a
e.x = a
n.z = h
n.o = h
n.y = g
n.r = g
assert n.z.q.u.o.q.txt == "a"