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

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

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

a = A("a")
f = B("f")
d = C("d")
c = B("c")
m = A("m")
g = C("g")
k = A("k")
i = B("i")
j = A("j")

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

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

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

a = A("a")
f = B("f")
d = C("d")
c = B("c")
m = A("m")
g = C("g")
k = A("k")
i = B("i")
j = A("j")

a.y = j
a.v = m
a.s = d
f.u = d
f.v = c
f.r = a
d.s = k
c.u = d
c.v = f
c.r = j
m.y = k
m.v = k
m.s = d
g.s = a
k.y = j
k.v = a
k.s = d
i.u = g
i.v = c
i.r = m
j.y = m
j.v = k
j.s = g
assert f.v.r.v.s.s.txt == "k"