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

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

c = A("c")
a = B("a")
b = A("b")
f = B("f")
e = A("e")
j = A("j")
i = B("i")
l = B("l")
g = A("g")

c.s = j
a.q = j
a.w = e
b.s = e
f.q = j
f.w = e
e.s = c
j.s = b
i.q = j
i.w = g
l.q = g
l.w = g
g.s = j
assert c.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.q: A = None
        self.w: A = None
        self.txt = txt

c = A("c")
a = B("a")
b = A("b")
f = B("f")
e = A("e")
j = A("j")
i = B("i")
l = B("l")
g = A("g")

c.s = j
a.q = j
a.w = e
b.s = e
f.q = j
f.w = e
e.s = c
j.s = b
i.q = j
i.w = g
l.q = g
l.w = g
g.s = j
assert c.s.s.s.s.s.s.s.s.txt == "c"