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

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

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

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

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

g.u = h
g.t = c
d.t = g
d.x = g
d.v = m
d.r = i
c.q = m
c.p = m
c.y = m
c.r = i
m.t = g
m.r = g
m.z = g
m.s = c
b.t = g
b.x = g
b.v = m
b.r = c
h.t = g
h.x = g
h.v = m
h.r = i
i.q = m
i.p = m
i.y = m
i.r = c
a.t = g
a.x = g
a.v = m
a.r = c
n.t = g
n.x = g
n.v = m
n.r = i
l.t = g
l.x = g
l.v = m
l.r = c
assert n.v.s.r.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.t: C = None
        self.txt = txt

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

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

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

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

g.u = h
g.t = c
d.t = g
d.x = g
d.v = m
d.r = i
c.q = m
c.p = m
c.y = m
c.r = i
m.t = g
m.r = g
m.z = g
m.s = c
b.t = g
b.x = g
b.v = m
b.r = c
h.t = g
h.x = g
h.v = m
h.r = i
i.q = m
i.p = m
i.y = m
i.r = c
a.t = g
a.x = g
a.v = m
a.r = c
n.t = g
n.x = g
n.v = m
n.r = i
l.t = g
l.x = g
l.v = m
l.r = c
assert n.v.s.r.txt == "i"