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

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

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

c = A("c")
j = B("j")
k = C("k")
f = B("f")

c.r = j
c.w = f
j.v = k
j.r = c
k.u = f
k.p = f
k.o = j
f.v = k
f.r = c
assert c.r.v.o.v.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.w: B = None
        self.txt = txt

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

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

c = A("c")
j = B("j")
k = C("k")
f = B("f")

c.r = j
c.w = f
j.v = k
j.r = c
k.u = f
k.p = f
k.o = j
f.v = k
f.r = c
assert c.r.v.o.v.txt == "k"