class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

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

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

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

h.x = a
j.y = h
j.p = g
j.u = g
a.o = j
g.w = j
g.u = k
g.t = k
g.o = a
k.w = a
assert h.x.o.u.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

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

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

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

h.x = a
j.y = h
j.p = g
j.u = g
a.o = j
g.w = j
g.u = k
g.t = k
g.o = a
k.w = a
assert h.x.o.u.o.o.txt == "j"