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

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

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

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

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

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

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

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

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

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

a.q = b
f.p = c
f.z = e
k.x = h
k.v = h
k.z = e
k.y = c
b.p = f
h.x = k
h.v = k
h.z = e
h.y = f
e.p = c
n.q = e
d.x = k
d.v = k
d.z = b
d.y = f
c.p = f
c.z = e
assert h.x.y.p.z.txt == "e"