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

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

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

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

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

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

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

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

h.u = f
c.x = b
c.w = l
c.y = a
g.x = h
k.u = g
b.x = h
f.x = k
a.x = g
a.w = l
a.y = c
l.u = f
assert g.x.u.x.u.x.u.x.txt == "k"