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

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

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

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

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

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

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

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

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

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

m.r = i
m.q = k
h.x = a
h.u = m
h.t = i
e.o = l
e.u = i
k.u = f
k.p = a
f.r = e
f.q = k
l.o = e
l.u = i
a.r = i
a.q = k
i.o = e
i.u = e
assert f.r.o.u.o.o.txt == "l"