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

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

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

g = A("g")
e = B("e")
i = C("i")
j = B("j")
h = C("h")
c = C("c")
f = C("f")

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

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

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

g = A("g")
e = B("e")
i = C("i")
j = B("j")
h = C("h")
c = C("c")
f = C("f")

g.v = e
e.v = f
i.r = g
i.v = e
i.z = h
j.v = i
h.r = g
h.v = e
h.z = i
c.r = g
c.v = e
c.z = f
f.r = g
f.v = e
f.z = h
assert i.v.v.z.r.v.txt == "e"