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

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

class C:
    def __init__(self, txt: str):
        self.s: D = None
        self.x: E = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.z: A = None
        self.x: A = None
        self.q: B = None
        self.s: A = None
        self.v: B = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

i = A("i")
l = B("l")
h = C("h")
d = D("d")
f = E("f")

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

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

class C:
    def __init__(self, txt: str):
        self.s: D = None
        self.x: E = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.z: A = None
        self.x: A = None
        self.q: B = None
        self.s: A = None
        self.v: B = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

i = A("i")
l = B("l")
h = C("h")
d = D("d")
f = E("f")

i.y = d
i.x = l
l.x = i
l.r = i
l.z = f
h.s = d
h.x = f
d.z = i
d.x = i
d.s = i
d.q = l
d.v = l
f.x = h
assert i.y.v.z.x.txt == "h"