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

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

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

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

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

b.q = m
b.w = g
b.u = g
b.p = e
i.q = g
i.w = l
i.r = b
i.p = m
g.t = k
e.w = k
e.u = l
k.w = e
k.u = l
m.q = l
m.w = l
m.r = b
m.p = i
d.q = l
d.w = g
d.r = b
d.p = i
l.t = k
assert m.r.u.t.w.u.t.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.w: C = None
        self.u: C = None
        self.p: D = None
        self.txt = txt

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

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

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

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

b.q = m
b.w = g
b.u = g
b.p = e
i.q = g
i.w = l
i.r = b
i.p = m
g.t = k
e.w = k
e.u = l
k.w = e
k.u = l
m.q = l
m.w = l
m.r = b
m.p = i
d.q = l
d.w = g
d.r = b
d.p = i
l.t = k
assert m.r.u.t.w.u.t.txt == "k"