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

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

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

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

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

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

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

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

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

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

f.u = h
f.s = b
f.v = k
k.p = f
k.r = f
k.z = f
b.o = k
b.z = k
j.x = b
j.w = b
j.r = k
j.z = h
h.x = b
h.w = b
h.r = k
h.z = j
assert k.p.u.r.txt == "k"