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

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

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

a = A("a")
j = B("j")
n = C("n")
g = B("g")
d = B("d")
f = C("f")
e = B("e")

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

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

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

a = A("a")
j = B("j")
n = C("n")
g = B("g")
d = B("d")
f = C("f")
e = B("e")

a.r = d
j.v = f
j.r = g
j.z = g
n.v = a
n.o = f
n.r = f
g.v = f
g.r = d
g.z = e
d.v = n
d.r = j
d.z = g
f.v = a
f.o = n
f.r = n
e.v = f
e.r = g
e.z = j
assert f.r.v.r.txt == "d"