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

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

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

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

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

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

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

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

f.x = n
f.q = j
m.t = i
m.s = j
m.r = f
n.r = m
n.w = j
n.v = i
j.r = m
j.w = n
j.v = i
i.x = j
i.q = n
assert i.x.w.v.q.txt == "n"