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

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

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

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

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

g = A("g")
j = B("j")
k = C("k")
d = D("d")
h = E("h")

g.o = h
g.w = j
j.s = d
j.o = k
j.t = k
k.q = d
k.s = g
d.z = j
d.s = h
d.y = k
h.t = g
h.p = j
assert h.t.o.p.txt == "
class A:
    def __init__(self, txt: str):
        self.o: E = None
        self.w: B = None
        self.txt = txt

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

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

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

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

g = A("g")
j = B("j")
k = C("k")
d = D("d")
h = E("h")

g.o = h
g.w = j
j.s = d
j.o = k
j.t = k
k.q = d
k.s = g
d.z = j
d.s = h
d.y = k
h.t = g
h.p = j
assert h.t.o.p.txt == "j"