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

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

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

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

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

h = A("h")
b = B("b")
j = C("j")
c = D("c")
l = E("l")
n = C("n")
g = C("g")

h.x = n
b.x = j
j.s = l
j.z = g
c.y = n
l.o = c
l.x = c
l.s = b
n.s = l
n.z = g
g.s = l
g.z = n
assert l.s.x.s.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

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

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

h = A("h")
b = B("b")
j = C("j")
c = D("c")
l = E("l")
n = C("n")
g = C("g")

h.x = n
b.x = j
j.s = l
j.z = g
c.y = n
l.o = c
l.x = c
l.s = b
n.s = l
n.z = g
g.s = l
g.z = n
assert l.s.x.s.x.txt == "c"