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

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

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

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

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

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

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

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

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

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

c.y = n
c.r = d
c.p = e
c.q = b
e.w = d
e.r = d
e.u = c
b.x = e
k.q = b
n.y = c
n.r = d
n.p = h
n.q = b
d.q = b
h.w = k
h.r = k
h.u = n
assert h.w.q.x.r.q.txt == "b"