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

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

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

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

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

g.o = d
g.p = i
g.y = i
i.y = k
i.z = k
b.r = i
k.p = l
l.o = d
l.p = i
l.y = i
d.r = i
m.o = b
m.p = i
m.y = i
assert l.o.r.z.p.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.p: B = None
        self.y: B = None
        self.txt = txt

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

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

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

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

g.o = d
g.p = i
g.y = i
i.y = k
i.z = k
b.r = i
k.p = l
l.o = d
l.p = i
l.y = i
d.r = i
m.o = b
m.p = i
m.y = i
assert l.o.r.z.p.o.r.txt == "i"