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

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

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

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

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

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

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

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

l.s = n
l.y = i
i.x = l
h.w = f
h.x = g
g.x = n
j.x = n
n.s = l
n.y = m
f.w = h
f.x = i
a.x = n
m.x = n
assert n.s.s.y.x.s.y.x.txt == "l"