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

class B:
    def __init__(self, txt: str):
        self.x: A = None
        self.q: B = None
        self.s: C = 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.s: B = None
        self.p: B = None
        self.txt = txt

n = A("n")
e = B("e")
j = C("j")
c = D("c")
h = B("h")

n.t = h
n.p = j
e.x = n
e.q = h
e.s = j
j.o = e
c.s = e
c.p = h
h.x = n
h.q = e
h.s = j
assert j.o.x.t.q.s.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.p: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: A = None
        self.q: B = None
        self.s: C = 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.s: B = None
        self.p: B = None
        self.txt = txt

n = A("n")
e = B("e")
j = C("j")
c = D("c")
h = B("h")

n.t = h
n.p = j
e.x = n
e.q = h
e.s = j
j.o = e
c.s = e
c.p = h
h.x = n
h.q = e
h.s = j
assert j.o.x.t.q.s.txt == "j"