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

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

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

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

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

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

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

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

m.v = j
g.x = i
g.q = e
g.w = h
h.s = m
c.v = j
e.x = c
e.q = g
e.w = n
i.v = j
j.s = i
n.s = i
assert i.v.s.v.s.v.txt == "j"