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

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

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

l = A("l")
m = B("m")
e = C("e")
g = A("g")
j = C("j")
b = C("b")
f = C("f")
h = A("h")
n = A("n")
i = A("i")

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

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

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

l = A("l")
m = B("m")
e = C("e")
g = A("g")
j = C("j")
b = C("b")
f = C("f")
h = A("h")
n = A("n")
i = A("i")

l.y = i
l.v = g
m.y = b
m.w = n
e.s = j
g.y = h
g.v = n
j.s = f
b.s = j
f.s = b
h.y = i
h.v = l
n.y = h
n.v = i
i.y = g
i.v = l
assert h.v.v.y.v.v.txt == "g"