class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.s: C = 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.r: B = None
        self.txt = txt

k = A("k")
a = B("a")
g = C("g")
j = B("j")

k.u = a
k.s = g
a.v = j
g.r = a
j.v = a
assert g.r.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.s: C = 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.r: B = None
        self.txt = txt

k = A("k")
a = B("a")
g = C("g")
j = B("j")

k.u = a
k.s = g
a.v = j
g.r = a
j.v = a
assert g.r.v.v.v.txt == "j"