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

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

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

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

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

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

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

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

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

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

e.p = m
e.u = h
h.t = m
h.u = c
n.x = e
n.s = e
c.q = n
m.t = h
m.u = c
assert h.u.q.x.u.txt == "h"