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

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

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

g = A("g")
k = B("k")
e = C("e")
j = A("j")
h = C("h")
n = C("n")

g.r = k
k.o = j
k.v = j
e.o = j
e.z = j
j.r = k
h.o = j
h.z = g
n.o = j
n.z = g
assert n.o.r.v.r.o.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

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

g = A("g")
k = B("k")
e = C("e")
j = A("j")
h = C("h")
n = C("n")

g.r = k
k.o = j
k.v = j
e.o = j
e.z = j
j.r = k
h.o = j
h.z = g
n.o = j
n.z = g
assert n.o.r.v.r.o.txt == "j"