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

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

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

n = A("n")
e = B("e")
d = C("d")
f = B("f")
l = C("l")
j = A("j")
m = B("m")
b = A("b")
c = B("c")
h = C("h")

n.s = e
n.x = f
n.r = b
e.x = n
e.p = c
d.q = b
d.v = e
d.r = h
f.x = n
f.p = m
l.q = j
l.v = e
l.r = h
j.s = m
j.x = f
j.r = n
m.x = n
m.p = e
b.s = c
b.x = f
b.r = n
c.x = j
c.p = f
h.q = b
h.v = m
h.r = d
assert h.r.r.v.x.s.x.r.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.x: B = None
        self.r: A = None
        self.txt = txt

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

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

n = A("n")
e = B("e")
d = C("d")
f = B("f")
l = C("l")
j = A("j")
m = B("m")
b = A("b")
c = B("c")
h = C("h")

n.s = e
n.x = f
n.r = b
e.x = n
e.p = c
d.q = b
d.v = e
d.r = h
f.x = n
f.p = m
l.q = j
l.v = e
l.r = h
j.s = m
j.x = f
j.r = n
m.x = n
m.p = e
b.s = c
b.x = f
b.r = n
c.x = j
c.p = f
h.q = b
h.v = m
h.r = d
assert h.r.r.v.x.s.x.r.txt == "b"