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

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

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

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

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

e.r = f
e.x = m
e.q = k
k.p = b
k.x = l
k.s = i
b.r = k
b.o = l
d.r = e
d.s = b
f.r = e
f.x = i
f.q = k
l.p = b
l.x = k
l.s = d
m.r = f
m.s = b
i.r = e
i.s = b
assert k.x.p.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.x: D = None
        self.q: B = None
        self.txt = txt

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

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

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

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

e.r = f
e.x = m
e.q = k
k.p = b
k.x = l
k.s = i
b.r = k
b.o = l
d.r = e
d.s = b
f.r = e
f.x = i
f.q = k
l.p = b
l.x = k
l.s = d
m.r = f
m.s = b
i.r = e
i.s = b
assert k.x.p.r.txt == "k"