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

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

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

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

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

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

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

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

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

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

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