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

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

m = A("m")
g = B("g")
f = B("f")
a = B("a")
i = A("i")
l = B("l")
h = B("h")
d = A("d")

m.u = a
m.x = i
g.t = f
g.s = i
f.t = g
f.s = i
a.t = g
a.s = m
i.u = a
i.x = d
l.t = a
l.s = d
h.t = g
h.s = i
d.u = a
d.x = m
assert a.t.t.t.t.s.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.x: A = None
        self.txt = txt

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

m = A("m")
g = B("g")
f = B("f")
a = B("a")
i = A("i")
l = B("l")
h = B("h")
d = A("d")

m.u = a
m.x = i
g.t = f
g.s = i
f.t = g
f.s = i
a.t = g
a.s = m
i.u = a
i.x = d
l.t = a
l.s = d
h.t = g
h.s = i
d.u = a
d.x = m
assert a.t.t.t.t.s.u.txt == "a"