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

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

class C:
    def __init__(self, txt: str):
        self.w: D = None
        self.txt = txt

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

c = A("c")
f = B("f")
b = C("b")
h = D("h")
d = A("d")
j = D("j")
a = D("a")

c.p = f
c.x = b
c.z = d
c.q = d
f.s = b
f.x = b
f.z = a
b.w = a
h.p = j
h.z = d
h.w = c
d.p = f
d.x = b
d.z = c
d.q = c
j.p = h
j.z = c
j.w = d
a.p = h
a.z = d
a.w = d
assert a.z.z.q.p.x.w.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.x: C = None
        self.z: A = None
        self.q: A = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.w: D = None
        self.txt = txt

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

c = A("c")
f = B("f")
b = C("b")
h = D("h")
d = A("d")
j = D("j")
a = D("a")

c.p = f
c.x = b
c.z = d
c.q = d
f.s = b
f.x = b
f.z = a
b.w = a
h.p = j
h.z = d
h.w = c
d.p = f
d.x = b
d.z = c
d.q = c
j.p = h
j.z = c
j.w = d
a.p = h
a.z = d
a.w = d
assert a.z.z.q.p.x.w.p.txt == "h"