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

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

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

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

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

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

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

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

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

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

m.r = g
m.p = l
m.t = j
m.o = k
a.s = d
g.q = k
g.x = l
g.r = j
g.s = d
j.p = k
l.r = g
l.p = k
l.t = j
l.o = m
d.s = a
k.r = g
k.p = l
k.t = j
k.o = m
assert j.p.p.t.p.txt == "k"