class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.x: D = None
        self.u: C = None
        self.txt = txt

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

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

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

l = A("l")
b = B("b")
n = C("n")
m = D("m")
i = A("i")
d = D("d")
k = A("k")

l.t = n
l.u = n
l.x = m
b.r = i
b.x = m
n.p = i
n.o = b
n.t = b
m.w = d
m.t = n
m.s = k
i.t = n
i.u = n
i.x = m
d.w = m
d.t = n
d.s = k
k.t = n
k.u = n
k.x = d
assert m.w.s.x.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.x: D = None
        self.u: C = None
        self.txt = txt

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

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

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

l = A("l")
b = B("b")
n = C("n")
m = D("m")
i = A("i")
d = D("d")
k = A("k")

l.t = n
l.u = n
l.x = m
b.r = i
b.x = m
n.p = i
n.o = b
n.t = b
m.w = d
m.t = n
m.s = k
i.t = n
i.u = n
i.x = m
d.w = m
d.t = n
d.s = k
k.t = n
k.u = n
k.x = d
assert m.w.s.x.txt == "d"