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

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

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

c = A("c")
b = B("b")
i = C("i")
j = B("j")
f = A("f")
g = C("g")
k = B("k")

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

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

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

c = A("c")
b = B("b")
i = C("i")
j = B("j")
f = A("f")
g = C("g")
k = B("k")

c.y = i
c.u = b
b.r = i
i.v = g
i.u = g
j.r = i
f.y = i
f.u = j
g.v = i
g.u = i
k.r = g
assert b.r.v.u.v.txt == "g"