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

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

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

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

a = A("a")
h = B("h")
b = C("b")
i = D("i")
e = A("e")
n = A("n")
m = D("m")
k = C("k")

a.r = i
h.w = i
b.u = i
b.o = e
b.t = n
i.q = a
i.r = b
e.r = i
n.r = i
m.q = n
m.r = b
k.u = m
k.o = n
k.t = n
assert m.r.t.r.r.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

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

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

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

a = A("a")
h = B("h")
b = C("b")
i = D("i")
e = A("e")
n = A("n")
m = D("m")
k = C("k")

a.r = i
h.w = i
b.u = i
b.o = e
b.t = n
i.q = a
i.r = b
e.r = i
n.r = i
m.q = n
m.r = b
k.u = m
k.o = n
k.t = n
assert m.r.t.r.r.o.r.txt == "i"