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.txt = txt

c = A("c")
n = B("n")
e = B("e")
b = A("b")
m = A("m")

c.s = m
n.q = m
e.q = m
b.s = c
m.s = c
assert b.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.txt = txt

c = A("c")
n = B("n")
e = B("e")
b = A("b")
m = A("m")

c.s = m
n.q = m
e.q = m
b.s = c
m.s = c
assert b.s.s.s.s.s.txt == "c"