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

class B:
    def __init__(self, txt: str):
        self.z: C = None
        self.o: E = None
        self.p: A = None
        self.y: A = None
        self.txt = txt

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

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

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

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

g.t = h
c.z = b
c.o = h
c.p = g
c.y = g
b.z = h
b.w = c
b.q = c
b.v = c
e.s = g
e.o = b
h.q = g
h.y = b
assert h.y.z.y.txt == "
class A:
    def __init__(self, txt: str):
        self.t: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: C = None
        self.o: E = None
        self.p: A = None
        self.y: A = None
        self.txt = txt

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

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

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

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

g.t = h
c.z = b
c.o = h
c.p = g
c.y = g
b.z = h
b.w = c
b.q = c
b.v = c
e.s = g
e.o = b
h.q = g
h.y = b
assert h.y.z.y.txt == "b"