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

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

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

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

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

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

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