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

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

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

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

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

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

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