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

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

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

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

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

e.p = k
k.p = h
k.w = h
k.t = h
h.o = k
h.z = k
h.q = f
f.t = k
assert f.t.p.z.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

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

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

e.p = k
k.p = h
k.w = h
k.t = h
h.o = k
h.z = k
h.q = f
f.t = k
assert f.t.p.z.txt == "k"