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

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

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

i = A("i")
g = B("g")
j = C("j")
h = B("h")
m = C("m")
l = C("l")
b = B("b")
k = A("k")

i.s = k
g.v = j
g.w = k
j.w = i
j.v = h
h.v = j
h.w = i
m.w = i
m.v = b
l.w = i
l.v = g
b.v = j
b.w = i
k.s = i
assert l.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

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

i = A("i")
g = B("g")
j = C("j")
h = B("h")
m = C("m")
l = C("l")
b = B("b")
k = A("k")

i.s = k
g.v = j
g.w = k
j.w = i
j.v = h
h.v = j
h.w = i
m.w = i
m.v = b
l.w = i
l.v = g
b.v = j
b.w = i
k.s = i
assert l.v.v.v.v.txt == "j"