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

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

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

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

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

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

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

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

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

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

n.p = c
n.u = c
e.u = c
c.r = e
c.q = e
c.u = h
c.t = h
h.p = c
h.t = c
h.u = n
assert n.u.q.u.q.txt == "e"