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

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

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

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

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

a = A("a")
g = B("g")
b = C("b")
n = D("n")
h = E("h")

a.o = h
g.q = h
g.y = a
g.p = a
b.s = g
b.r = h
n.z = h
h.y = g
h.s = n
assert a.o.y.q.y.txt == "
class A:
    def __init__(self, txt: str):
        self.o: E = None
        self.txt = txt

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

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

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

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

a = A("a")
g = B("g")
b = C("b")
n = D("n")
h = E("h")

a.o = h
g.q = h
g.y = a
g.p = a
b.s = g
b.r = h
n.z = h
h.y = g
h.s = n
assert a.o.y.q.y.txt == "g"