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

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

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

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

l = A("l")
m = B("m")
i = C("i")
k = D("k")
a = D("a")
g = D("g")
d = B("d")
f = A("f")

l.r = f
l.q = f
l.u = f
l.t = a
m.q = l
i.x = f
i.p = d
k.t = i
k.u = m
k.v = f
k.s = g
a.t = i
a.u = d
a.v = f
a.s = k
g.t = i
g.u = m
g.v = f
g.s = a
d.q = l
f.r = l
f.q = l
f.u = l
f.t = a
assert k.t.p.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.t: D = None
        self.q: A = None
        self.u: A = None
        self.txt = txt

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

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

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

l = A("l")
m = B("m")
i = C("i")
k = D("k")
a = D("a")
g = D("g")
d = B("d")
f = A("f")

l.r = f
l.q = f
l.u = f
l.t = a
m.q = l
i.x = f
i.p = d
k.t = i
k.u = m
k.v = f
k.s = g
a.t = i
a.u = d
a.v = f
a.s = k
g.t = i
g.u = m
g.v = f
g.s = a
d.q = l
f.r = l
f.q = l
f.u = l
f.t = a
assert k.t.p.q.txt == "l"