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

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

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

j = A("j")
i = B("i")
l = C("l")
m = C("m")
f = A("f")
d = A("d")
n = B("n")
k = A("k")
c = B("c")

j.v = k
j.w = l
i.x = n
l.w = j
m.w = k
f.v = k
f.w = l
d.v = k
d.w = l
n.x = c
k.v = j
k.w = m
c.x = n
assert k.w.w.v.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.w: C = None
        self.txt = txt

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

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

j = A("j")
i = B("i")
l = C("l")
m = C("m")
f = A("f")
d = A("d")
n = B("n")
k = A("k")
c = B("c")

j.v = k
j.w = l
i.x = n
l.w = j
m.w = k
f.v = k
f.w = l
d.v = k
d.w = l
n.x = c
k.v = j
k.w = m
c.x = n
assert k.w.w.v.v.v.v.v.txt == "j"