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

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

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

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

l = A("l")
k = B("k")
j = C("j")
n = D("n")
c = D("c")
g = A("g")
f = D("f")
i = D("i")
a = D("a")
d = C("d")

l.r = g
l.y = j
k.r = d
k.x = f
k.u = l
k.t = l
j.z = g
j.y = c
j.w = d
j.p = k
n.q = d
c.q = d
g.r = l
g.y = d
f.q = j
i.q = j
a.q = d
d.z = l
d.y = c
d.w = j
d.p = k
assert n.q.z.y.z.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.y: C = None
        self.txt = txt

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

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

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

l = A("l")
k = B("k")
j = C("j")
n = D("n")
c = D("c")
g = A("g")
f = D("f")
i = D("i")
a = D("a")
d = C("d")

l.r = g
l.y = j
k.r = d
k.x = f
k.u = l
k.t = l
j.z = g
j.y = c
j.w = d
j.p = k
n.q = d
c.q = d
g.r = l
g.y = d
f.q = j
i.q = j
a.q = d
d.z = l
d.y = c
d.w = j
d.p = k
assert n.q.z.y.z.r.txt == "l"