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

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

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

g = A("g")
i = B("i")
d = C("d")
j = B("j")
k = C("k")

g.v = d
g.r = j
i.v = j
i.u = d
d.s = k
d.o = g
j.v = i
j.u = d
k.s = d
k.o = g
assert j.v.v.u.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.r: B = None
        self.txt = txt

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

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

g = A("g")
i = B("i")
d = C("d")
j = B("j")
k = C("k")

g.v = d
g.r = j
i.v = j
i.u = d
d.s = k
d.o = g
j.v = i
j.u = d
k.s = d
k.o = g
assert j.v.v.u.txt == "d"