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

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

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

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

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

l.y = n
l.x = k
l.q = f
l.t = b
g.r = d
f.r = a
f.v = a
f.y = d
f.o = k
b.z = n
a.r = f
k.r = d
d.r = g
d.v = a
d.o = a
d.y = f
m.y = n
m.t = n
m.x = k
m.q = d
j.y = n
j.t = n
j.x = g
j.q = d
n.z = b
assert k.r.y.o.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.x: B = None
        self.q: C = None
        self.t: D = None
        self.txt = txt

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

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

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

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

l.y = n
l.x = k
l.q = f
l.t = b
g.r = d
f.r = a
f.v = a
f.y = d
f.o = k
b.z = n
a.r = f
k.r = d
d.r = g
d.v = a
d.o = a
d.y = f
m.y = n
m.t = n
m.x = k
m.q = d
j.y = n
j.t = n
j.x = g
j.q = d
n.z = b
assert k.r.y.o.r.r.r.txt == "d"