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

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

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

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

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

j.r = g
j.s = n
j.w = k
j.u = l
i.p = n
g.q = m
n.y = g
n.r = g
l.r = g
l.s = n
l.w = k
l.u = j
k.y = g
k.r = g
d.y = g
d.r = g
b.y = g
b.r = g
m.p = d
a.p = k
assert g.q.p.r.q.p.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.s: D = None
        self.w: D = None
        self.u: A = None
        self.txt = txt

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

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

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

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

j.r = g
j.s = n
j.w = k
j.u = l
i.p = n
g.q = m
n.y = g
n.r = g
l.r = g
l.s = n
l.w = k
l.u = j
k.y = g
k.r = g
d.y = g
d.r = g
b.y = g
b.r = g
m.p = d
a.p = k
assert g.q.p.r.q.p.r.txt == "g"