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

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

a = A("a")
l = B("l")
d = A("d")
n = B("n")
f = B("f")
b = A("b")
g = A("g")
k = A("k")
j = A("j")

a.t = k
a.s = j
l.s = f
d.t = b
d.s = g
n.s = l
f.s = l
b.t = j
b.s = j
g.t = k
g.s = a
k.t = b
k.s = d
j.t = b
j.s = b
assert g.s.s.s.s.s.t.s.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.s: A = None
        self.txt = txt

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

a = A("a")
l = B("l")
d = A("d")
n = B("n")
f = B("f")
b = A("b")
g = A("g")
k = A("k")
j = A("j")

a.t = k
a.s = j
l.s = f
d.t = b
d.s = g
n.s = l
f.s = l
b.t = j
b.s = j
g.t = k
g.s = a
k.t = b
k.s = d
j.t = b
j.s = b
assert g.s.s.s.s.s.t.s.txt == "b"