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

class B:
    def __init__(self, txt: str):
        self.y: E = None
        self.txt = txt

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

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

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

c = A("c")
j = B("j")
h = C("h")
i = D("i")
g = E("g")

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

class B:
    def __init__(self, txt: str):
        self.y: E = None
        self.txt = txt

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

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

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

c = A("c")
j = B("j")
h = C("h")
i = D("i")
g = E("g")

c.z = j
j.y = g
h.q = j
i.r = j
i.v = j
g.t = c
g.x = j
assert c.z.y.x.y.txt == "g"