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

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

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

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

h = A("h")
m = B("m")
k = C("k")
d = D("d")
f = C("f")
n = D("n")

h.t = m
h.w = d
h.y = f
m.s = f
m.p = k
k.r = f
k.z = f
k.w = h
k.o = h
d.x = n
d.q = n
f.r = k
f.z = k
f.w = h
f.o = h
n.x = d
n.q = d
assert f.w.y.z.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.w: D = None
        self.y: C = None
        self.txt = txt

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

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

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

h = A("h")
m = B("m")
k = C("k")
d = D("d")
f = C("f")
n = D("n")

h.t = m
h.w = d
h.y = f
m.s = f
m.p = k
k.r = f
k.z = f
k.w = h
k.o = h
d.x = n
d.q = n
f.r = k
f.z = k
f.w = h
f.o = h
n.x = d
n.q = d
assert f.w.y.z.txt == "k"