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

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

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

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

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

e.y = c
e.v = c
e.u = c
e.w = n
n.r = h
k.p = n
k.q = e
h.s = k
c.y = e
c.v = e
c.u = e
c.w = n
assert h.s.p.r.s.p.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.v: A = None
        self.w: B = None
        self.u: A = None
        self.txt = txt

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

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

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

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

e.y = c
e.v = c
e.u = c
e.w = n
n.r = h
k.p = n
k.q = e
h.s = k
c.y = e
c.v = e
c.u = e
c.w = n
assert h.s.p.r.s.p.txt == "n"