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

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

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

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

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

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

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

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

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

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

l.o = h
l.z = m
l.r = f
c.w = l
c.r = l
f.p = e
e.t = c
e.z = m
d.w = l
d.r = g
g.o = f
g.r = f
g.z = l
b.w = g
b.r = i
i.o = h
i.r = h
i.z = m
h.p = e
m.o = h
m.r = h
m.z = g
assert e.t.r.z.r.p.txt == "e"