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

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

j = A("j")
h = B("h")
i = B("i")
m = A("m")
c = B("c")
d = A("d")
g = B("g")
f = A("f")
b = A("b")
l = B("l")

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

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

j = A("j")
h = B("h")
i = B("i")
m = A("m")
c = B("c")
d = A("d")
g = B("g")
f = A("f")
b = A("b")
l = B("l")

j.s = b
j.u = g
h.t = f
h.q = c
i.t = j
i.q = l
m.s = f
m.u = c
c.t = f
c.q = h
d.s = j
d.u = i
g.t = b
g.q = h
f.s = d
f.u = l
b.s = m
b.u = l
l.t = d
l.q = c
assert h.q.t.s.txt == "d"