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

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

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

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

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

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

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

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

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