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

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

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

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

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

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

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

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

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