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

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

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

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

j = A("j")
c = B("c")
a = C("a")
l = D("l")
e = D("e")
h = B("h")
m = B("m")
i = D("i")
g = B("g")
b = A("b")

j.r = l
c.z = i
c.r = a
a.y = l
a.t = j
l.p = b
l.y = i
l.w = j
l.q = e
e.p = j
e.w = j
e.y = i
e.q = l
h.z = l
h.r = a
m.z = l
m.r = a
i.p = b
i.y = e
i.w = j
i.q = l
g.z = i
g.r = a
b.r = e
assert m.z.p.r.y.q.y.q.p.r.y.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

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

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

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

j = A("j")
c = B("c")
a = C("a")
l = D("l")
e = D("e")
h = B("h")
m = B("m")
i = D("i")
g = B("g")
b = A("b")

j.r = l
c.z = i
c.r = a
a.y = l
a.t = j
l.p = b
l.y = i
l.w = j
l.q = e
e.p = j
e.w = j
e.y = i
e.q = l
h.z = l
h.r = a
m.z = l
m.r = a
i.p = b
i.y = e
i.w = j
i.q = l
g.z = i
g.r = a
b.r = e
assert m.z.p.r.y.q.y.q.p.r.y.txt == "i"