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

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

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

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

a = A("a")
f = B("f")
k = C("k")
i = D("i")
e = B("e")
l = A("l")
d = A("d")
b = B("b")

a.p = i
a.u = k
a.y = k
a.q = l
f.z = i
f.v = e
k.r = b
k.x = b
k.y = d
k.s = a
i.s = k
e.z = i
e.v = b
l.p = i
l.u = k
l.y = k
l.q = d
d.p = i
d.u = k
d.y = k
d.q = l
b.z = i
b.v = e
assert f.z.s.x.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.u: C = None
        self.q: A = None
        self.y: C = None
        self.txt = txt

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

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

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

a = A("a")
f = B("f")
k = C("k")
i = D("i")
e = B("e")
l = A("l")
d = A("d")
b = B("b")

a.p = i
a.u = k
a.y = k
a.q = l
f.z = i
f.v = e
k.r = b
k.x = b
k.y = d
k.s = a
i.s = k
e.z = i
e.v = b
l.p = i
l.u = k
l.y = k
l.q = d
d.p = i
d.u = k
d.y = k
d.q = l
b.z = i
b.v = e
assert f.z.s.x.v.v.txt == "b"