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

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

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

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

j = A("j")
g = B("g")
l = C("l")
b = D("b")
d = C("d")
m = A("m")
f = C("f")
k = D("k")

j.w = m
j.t = m
j.u = g
j.q = g
g.q = k
g.p = k
g.v = b
g.o = m
l.p = d
l.u = b
b.y = g
b.v = f
b.t = k
d.p = f
d.u = b
m.w = j
m.t = j
m.u = g
m.q = g
f.p = l
f.u = k
k.y = g
k.v = f
k.t = b
assert m.t.t.u.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.u: B = None
        self.t: A = None
        self.q: B = None
        self.txt = txt

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

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

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

j = A("j")
g = B("g")
l = C("l")
b = D("b")
d = C("d")
m = A("m")
f = C("f")
k = D("k")

j.w = m
j.t = m
j.u = g
j.q = g
g.q = k
g.p = k
g.v = b
g.o = m
l.p = d
l.u = b
b.y = g
b.v = f
b.t = k
d.p = f
d.u = b
m.w = j
m.t = j
m.u = g
m.q = g
f.p = l
f.u = k
k.y = g
k.v = f
k.t = b
assert m.t.t.u.txt == "g"