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

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

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

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

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

f = A("f")
k = B("k")
m = C("m")
i = D("i")
h = E("h")
l = A("l")
b = C("b")

f.p = i
f.s = k
k.y = l
m.x = h
m.p = i
m.y = i
m.z = i
i.s = b
h.s = i
h.q = f
l.p = i
l.s = k
b.x = h
b.p = i
b.y = i
b.z = i
assert k.y.p.s.z.s.z.s.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.s: B = None
        self.txt = txt

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

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

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

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

f = A("f")
k = B("k")
m = C("m")
i = D("i")
h = E("h")
l = A("l")
b = C("b")

f.p = i
f.s = k
k.y = l
m.x = h
m.p = i
m.y = i
m.z = i
i.s = b
h.s = i
h.q = f
l.p = i
l.s = k
b.x = h
b.p = i
b.y = i
b.z = i
assert k.y.p.s.z.s.z.s.txt == "b"