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

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

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

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

h = A("h")
c = B("c")
a = C("a")
b = D("b")
n = A("n")
k = C("k")
f = B("f")
e = B("e")
d = D("d")

h.z = a
h.q = n
c.s = f
c.p = h
a.y = d
a.p = c
a.u = n
b.q = d
b.t = h
n.z = a
n.q = h
k.y = b
k.p = e
k.u = h
f.s = c
f.p = n
e.s = f
e.p = h
d.q = b
d.t = h
assert f.s.p.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.q: A = None
        self.txt = txt

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

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

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

h = A("h")
c = B("c")
a = C("a")
b = D("b")
n = A("n")
k = C("k")
f = B("f")
e = B("e")
d = D("d")

h.z = a
h.q = n
c.s = f
c.p = h
a.y = d
a.p = c
a.u = n
b.q = d
b.t = h
n.z = a
n.q = h
k.y = b
k.p = e
k.u = h
f.s = c
f.p = n
e.s = f
e.p = h
d.q = b
d.t = h
assert f.s.p.z.txt == "a"