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

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

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

h = A("h")
k = B("k")
l = C("l")
f = A("f")
c = A("c")
j = C("j")
n = C("n")

h.x = n
h.v = k
h.w = k
k.p = c
k.q = c
k.v = f
l.w = c
f.x = j
f.v = k
f.w = k
c.x = l
c.v = k
c.w = k
j.w = h
n.w = c
assert l.w.v.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.v: B = None
        self.w: B = None
        self.txt = txt

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

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

h = A("h")
k = B("k")
l = C("l")
f = A("f")
c = A("c")
j = C("j")
n = C("n")

h.x = n
h.v = k
h.w = k
k.p = c
k.q = c
k.v = f
l.w = c
f.x = j
f.v = k
f.w = k
c.x = l
c.v = k
c.w = k
j.w = h
n.w = c
assert l.w.v.q.txt == "c"