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

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

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

h = A("h")
c = B("c")
j = C("j")
n = A("n")
m = C("m")
a = A("a")
l = A("l")

h.w = m
c.x = j
c.v = l
c.y = n
j.q = h
j.v = c
j.t = m
n.w = m
m.q = h
m.v = c
m.t = j
a.w = j
l.w = j
assert a.w.v.x.q.w.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

h = A("h")
c = B("c")
j = C("j")
n = A("n")
m = C("m")
a = A("a")
l = A("l")

h.w = m
c.x = j
c.v = l
c.y = n
j.q = h
j.v = c
j.t = m
n.w = m
m.q = h
m.v = c
m.t = j
a.w = j
l.w = j
assert a.w.v.x.q.w.v.v.txt == "l"