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

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

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

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

k = A("k")
h = B("h")
e = C("e")
f = D("f")
j = B("j")

k.u = e
k.y = h
h.r = j
h.z = j
h.q = k
h.w = e
e.p = k
e.x = h
f.s = j
f.u = k
f.w = h
j.r = h
j.z = h
j.q = k
j.w = e
assert k.u.p.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.y: B = None
        self.txt = txt

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

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

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

k = A("k")
h = B("h")
e = C("e")
f = D("f")
j = B("j")

k.u = e
k.y = h
h.r = j
h.z = j
h.q = k
h.w = e
e.p = k
e.x = h
f.s = j
f.u = k
f.w = h
j.r = h
j.z = h
j.q = k
j.w = e
assert k.u.p.u.txt == "e"