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

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

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

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

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

h.x = d
n.t = k
e.o = j
m.r = i
a.x = n
k.t = n
j.t = d
b.r = m
d.t = n
i.r = b
assert a.x.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

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

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

h.x = d
n.t = k
e.o = j
m.r = i
a.x = n
k.t = n
j.t = d
b.r = m
d.t = n
i.r = b
assert a.x.t.t.txt == "n"