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

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

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

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

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

b.r = e
b.o = d
f.x = m
f.z = h
m.o = e
m.s = d
m.p = j
e.z = j
d.o = e
d.s = h
d.p = j
h.o = j
h.p = j
h.s = m
i.x = m
i.z = d
c.r = j
c.o = m
j.z = e
k.x = h
k.z = d
assert f.z.p.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.o: C = None
        self.txt = txt

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

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

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

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

b.r = e
b.o = d
f.x = m
f.z = h
m.o = e
m.s = d
m.p = j
e.z = j
d.o = e
d.s = h
d.p = j
h.o = j
h.p = j
h.s = m
i.x = m
i.z = d
c.r = j
c.o = m
j.z = e
k.x = h
k.z = d
assert f.z.p.z.z.z.txt == "e"