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

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

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

i = A("i")
g = B("g")
j = C("j")
l = C("l")
h = B("h")
d = C("d")
c = C("c")

i.z = g
g.r = l
g.x = i
g.s = h
j.y = i
j.v = i
l.y = i
l.v = i
h.r = d
h.x = i
h.s = g
d.y = i
d.v = i
c.y = i
c.v = i
assert j.v.z.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

i = A("i")
g = B("g")
j = C("j")
l = C("l")
h = B("h")
d = C("d")
c = C("c")

i.z = g
g.r = l
g.x = i
g.s = h
j.y = i
j.v = i
l.y = i
l.v = i
h.r = d
h.x = i
h.s = g
d.y = i
d.v = i
c.y = i
c.v = i
assert j.v.z.s.txt == "h"