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

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

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

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

n = A("n")
g = B("g")
l = C("l")
d = D("d")
j = D("j")
a = C("a")
f = B("f")

n.r = g
n.y = g
n.s = f
g.x = f
g.u = f
g.r = a
g.y = n
l.x = f
l.u = g
d.t = l
d.z = n
j.t = l
j.z = n
a.x = f
a.u = g
f.x = g
f.u = g
f.r = a
f.y = n
assert g.y.s.x.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.y: B = None
        self.s: B = None
        self.txt = txt

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

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

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

n = A("n")
g = B("g")
l = C("l")
d = D("d")
j = D("j")
a = C("a")
f = B("f")

n.r = g
n.y = g
n.s = f
g.x = f
g.u = f
g.r = a
g.y = n
l.x = f
l.u = g
d.t = l
d.z = n
j.t = l
j.z = n
a.x = f
a.u = g
f.x = g
f.u = g
f.r = a
f.y = n
assert g.y.s.x.r.txt == "a"