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

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

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

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

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

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

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

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

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

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

m.o = h
m.r = k
m.x = l
c.p = k
f.q = h
f.r = l
f.p = m
l.z = m
l.t = m
l.q = c
h.q = f
h.r = l
h.p = m
g.z = m
g.q = i
g.t = k
e.o = f
e.r = m
e.x = l
k.o = h
k.r = m
k.x = l
i.p = m
assert i.p.x.q.p.o.r.txt == "l"