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

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

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

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

d = A("d")
b = B("b")
j = C("j")
l = D("l")
k = B("k")
i = C("i")
m = D("m")
a = A("a")

d.o = l
d.p = i
b.t = j
b.r = m
j.p = d
j.o = i
l.p = m
l.z = a
k.t = j
k.r = m
i.p = a
i.o = j
m.p = l
m.z = a
a.o = l
a.p = j
assert l.z.p.o.p.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.p: C = None
        self.txt = txt

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

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

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

d = A("d")
b = B("b")
j = C("j")
l = D("l")
k = B("k")
i = C("i")
m = D("m")
a = A("a")

d.o = l
d.p = i
b.t = j
b.r = m
j.p = d
j.o = i
l.p = m
l.z = a
k.t = j
k.r = m
i.p = a
i.o = j
m.p = l
m.z = a
a.o = l
a.p = j
assert l.z.p.o.p.p.p.p.p.txt == "a"