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

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

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

e = A("e")
j = B("j")
d = C("d")
h = B("h")
c = A("c")

e.v = j
j.x = e
j.y = c
j.z = h
d.z = h
d.w = j
h.x = c
h.y = e
h.z = j
c.v = j
assert e.v.x.v.z.y.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

e = A("e")
j = B("j")
d = C("d")
h = B("h")
c = A("c")

e.v = j
j.x = e
j.y = c
j.z = h
d.z = h
d.w = j
h.x = c
h.y = e
h.z = j
c.v = j
assert e.v.x.v.z.y.txt == "e"