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

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

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

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

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

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

a.t = g
a.x = j
c.t = h
c.o = a
h.s = a
j.o = g
g.s = c
assert j.o.s.t.s.txt == "
class A:
    def __init__(self, txt: str):
        self.t: E = None
        self.x: D = None
        self.txt = txt

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

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

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

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

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

a.t = g
a.x = j
c.t = h
c.o = a
h.s = a
j.o = g
g.s = c
assert j.o.s.t.s.txt == "a"