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

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

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

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

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

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

g.t = k
g.u = h
l.o = g
l.y = g
l.v = g
l.w = h
b.z = l
k.q = g
h.q = g
h.u = b
h.v = b
assert k.q.t.q.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.u: E = None
        self.txt = txt

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

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

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

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

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

g.t = k
g.u = h
l.o = g
l.y = g
l.v = g
l.w = h
b.z = l
k.q = g
h.q = g
h.u = b
h.v = b
assert k.q.t.q.txt == "g"