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: B = None
        self.txt = txt

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

l.t = d
l.q = d
n.s = g
c.t = n
c.q = d
f.t = d
f.q = d
d.s = g
e.t = d
e.q = g
g.s = n
k.t = d
k.q = g
assert c.t.s.s.s.s.s.s.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: B = None
        self.txt = txt

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

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