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

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

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

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

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

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

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

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

k.y = a
k.v = a
k.x = c
l.s = g
l.t = f
l.r = k
a.s = g
a.p = l
a.r = l
g.s = a
g.p = l
g.r = f
c.y = g
c.v = g
c.x = k
d.y = a
d.v = a
d.x = c
f.s = g
f.t = l
f.r = d
assert a.r.r.x.x.y.s.p.txt == "l"