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

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

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

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

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

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

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