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

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

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

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

k = A("k")
f = B("f")
n = C("n")
l = D("l")
e = D("e")
b = C("b")
m = B("m")
j = A("j")

k.w = l
f.t = e
n.r = b
l.p = m
l.w = k
l.x = k
e.p = f
e.w = k
e.x = j
b.r = n
m.t = l
j.w = l
assert l.p.t.x.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.txt = txt

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

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

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

k = A("k")
f = B("f")
n = C("n")
l = D("l")
e = D("e")
b = C("b")
m = B("m")
j = A("j")

k.w = l
f.t = e
n.r = b
l.p = m
l.w = k
l.x = k
e.p = f
e.w = k
e.x = j
b.r = n
m.t = l
j.w = l
assert l.p.t.x.w.w.txt == "k"