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

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

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

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

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

k = A("k")
m = B("m")
n = C("n")
g = D("g")
i = E("i")

k.t = g
m.z = k
m.o = k
m.x = i
m.v = i
n.t = i
g.q = i
i.q = k
assert i.q.t.q.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.txt = txt

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

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

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

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

k = A("k")
m = B("m")
n = C("n")
g = D("g")
i = E("i")

k.t = g
m.z = k
m.o = k
m.x = i
m.v = i
n.t = i
g.q = i
i.q = k
assert i.q.t.q.txt == "i"