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

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

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

g = A("g")
f = B("f")
k = C("k")
c = C("c")
b = B("b")
a = A("a")
h = C("h")
m = A("m")

g.y = m
g.x = h
f.v = b
f.u = m
k.x = h
c.x = k
b.v = f
b.u = g
a.y = m
a.x = c
h.x = c
m.y = g
m.x = c
assert h.x.x.x.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.x: C = None
        self.txt = txt

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

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

g = A("g")
f = B("f")
k = C("k")
c = C("c")
b = B("b")
a = A("a")
h = C("h")
m = A("m")

g.y = m
g.x = h
f.v = b
f.u = m
k.x = h
c.x = k
b.v = f
b.u = g
a.y = m
a.x = c
h.x = c
m.y = g
m.x = c
assert h.x.x.x.x.x.x.x.txt == "c"