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

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

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

d = A("d")
e = B("e")
f = C("f")
j = A("j")
l = B("l")
k = C("k")
c = B("c")
g = A("g")
n = A("n")
m = A("m")

d.w = g
e.x = k
e.s = k
e.o = l
f.t = l
j.w = n
l.x = k
l.s = k
l.o = c
k.t = l
c.x = k
c.s = k
c.o = e
g.w = n
n.w = g
m.w = g
assert l.s.t.o.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

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

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

d = A("d")
e = B("e")
f = C("f")
j = A("j")
l = B("l")
k = C("k")
c = B("c")
g = A("g")
n = A("n")
m = A("m")

d.w = g
e.x = k
e.s = k
e.o = l
f.t = l
j.w = n
l.x = k
l.s = k
l.o = c
k.t = l
c.x = k
c.s = k
c.o = e
g.w = n
n.w = g
m.w = g
assert l.s.t.o.txt == "c"