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

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

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

j = A("j")
n = B("n")
f = C("f")
m = B("m")

j.q = f
j.y = f
j.s = m
n.x = j
f.w = j
m.x = j
assert m.x.s.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.y: C = None
        self.s: B = None
        self.txt = txt

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

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

j = A("j")
n = B("n")
f = C("f")
m = B("m")

j.q = f
j.y = f
j.s = m
n.x = j
f.w = j
m.x = j
assert m.x.s.x.txt == "j"