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

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

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

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

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

k = A("k")
c = B("c")
h = C("h")
f = D("f")
n = E("n")
a = E("a")
g = C("g")

k.t = f
k.s = c
c.x = g
c.t = k
h.x = f
h.o = n
f.o = n
f.y = h
n.x = k
a.x = k
g.x = f
g.o = n
assert k.t.o.x.t.y.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.s: B = None
        self.txt = txt

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

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

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

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

k = A("k")
c = B("c")
h = C("h")
f = D("f")
n = E("n")
a = E("a")
g = C("g")

k.t = f
k.s = c
c.x = g
c.t = k
h.x = f
h.o = n
f.o = n
f.y = h
n.x = k
a.x = k
g.x = f
g.o = n
assert k.t.o.x.t.y.txt == "h"