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

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

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

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

m.u = g
m.y = k
m.x = f
g.v = l
g.s = d
k.u = g
k.v = g
k.r = f
l.u = c
l.y = k
l.x = m
c.v = d
c.s = m
e.v = f
e.s = f
f.u = g
f.y = k
f.x = d
d.u = c
d.y = k
d.x = f
assert c.s.u.v.u.s.x.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.y: C = None
        self.x: A = None
        self.txt = txt

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

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

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

m.u = g
m.y = k
m.x = f
g.v = l
g.s = d
k.u = g
k.v = g
k.r = f
l.u = c
l.y = k
l.x = m
c.v = d
c.s = m
e.v = f
e.s = f
f.u = g
f.y = k
f.x = d
d.u = c
d.y = k
d.x = f
assert c.s.u.v.u.s.x.u.txt == "g"