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

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

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

f = A("f")
j = B("j")
c = C("c")
a = C("a")
d = B("d")
b = A("b")

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

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

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

f = A("f")
j = B("j")
c = C("c")
a = C("a")
d = B("d")
b = A("b")

f.z = j
j.o = a
j.r = a
j.v = d
c.r = f
c.v = b
a.r = f
a.v = b
d.o = a
d.r = a
d.v = j
b.z = j
assert d.o.r.z.r.txt == "a"