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

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

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

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

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

l = A("l")
b = B("b")
d = C("d")
c = D("c")
g = E("g")
h = E("h")

l.z = c
l.q = b
b.w = d
b.t = l
d.u = b
d.s = b
d.w = c
d.r = l
c.x = g
c.t = g
c.q = d
g.v = b
h.v = b
assert h.v.t.q.t.q.w.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.q: B = None
        self.txt = txt

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

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

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

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

l = A("l")
b = B("b")
d = C("d")
c = D("c")
g = E("g")
h = E("h")

l.z = c
l.q = b
b.w = d
b.t = l
d.u = b
d.s = b
d.w = c
d.r = l
c.x = g
c.t = g
c.q = d
g.v = b
h.v = b
assert h.v.t.q.t.q.w.txt == "d"