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

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

class C:
    def __init__(self, txt: str):
        self.o: B = None
        self.r: B = None
        self.txt = txt

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

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

a.o = l
a.r = l
a.z = l
e.p = l
l.o = h
l.r = k
f.w = a
i.o = l
i.r = l
i.z = l
d.w = i
b.w = a
h.p = l
c.w = i
k.p = l
assert l.o.p.r.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.r: C = None
        self.z: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.o: B = None
        self.r: B = None
        self.txt = txt

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

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

a.o = l
a.r = l
a.z = l
e.p = l
l.o = h
l.r = k
f.w = a
i.o = l
i.r = l
i.z = l
d.w = i
b.w = a
h.p = l
c.w = i
k.p = l
assert l.o.p.r.txt == "k"