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

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

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

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

j.v = h
m.x = i
i.q = j
n.x = i
h.v = j
g.x = i
f.x = i
assert n.x.q.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

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

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

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

j.v = h
m.x = i
i.q = j
n.x = i
h.v = j
g.x = i
f.x = i
assert n.x.q.v.v.txt == "j"