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

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

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

a = A("a")
m = B("m")
b = C("b")
n = C("n")
i = C("i")
d = C("d")
f = C("f")
j = B("j")
h = C("h")
c = A("c")

a.y = c
m.y = j
m.v = c
m.x = c
b.x = a
n.x = c
i.x = a
d.x = a
f.x = a
j.y = m
j.v = a
j.x = a
h.x = c
c.y = a
assert m.v.y.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

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

a = A("a")
m = B("m")
b = C("b")
n = C("n")
i = C("i")
d = C("d")
f = C("f")
j = B("j")
h = C("h")
c = A("c")

a.y = c
m.y = j
m.v = c
m.x = c
b.x = a
n.x = c
i.x = a
d.x = a
f.x = a
j.y = m
j.v = a
j.x = a
h.x = c
c.y = a
assert m.v.y.y.y.y.y.y.txt == "c"