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

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

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

d = A("d")
b = B("b")
n = C("n")
k = A("k")
i = B("i")
c = C("c")
l = A("l")
e = C("e")
g = B("g")
j = C("j")

d.r = k
b.y = i
b.z = n
n.x = i
n.s = e
k.r = l
i.y = b
i.z = e
c.x = i
c.s = n
l.r = d
e.x = i
e.s = n
g.y = i
g.z = n
j.x = b
j.s = c
assert b.y.z.x.y.z.s.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

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

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

d = A("d")
b = B("b")
n = C("n")
k = A("k")
i = B("i")
c = C("c")
l = A("l")
e = C("e")
g = B("g")
j = C("j")

d.r = k
b.y = i
b.z = n
n.x = i
n.s = e
k.r = l
i.y = b
i.z = e
c.x = i
c.s = n
l.r = d
e.x = i
e.s = n
g.y = i
g.z = n
j.x = b
j.s = c
assert b.y.z.x.y.z.s.txt == "e"