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

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

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

b = A("b")
c = B("c")
h = C("h")
e = A("e")
n = A("n")
k = A("k")
m = B("m")
a = A("a")
d = C("d")

b.p = h
b.s = h
b.x = c
c.y = m
c.q = d
c.p = d
h.o = d
h.v = d
h.y = m
e.p = h
e.x = m
e.s = d
n.p = d
n.x = m
n.s = h
k.p = d
k.x = c
k.s = h
m.y = c
m.q = d
m.p = d
a.p = h
a.s = h
a.x = m
d.o = h
d.v = h
d.y = m
assert b.s.y.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.x: B = None
        self.s: C = None
        self.txt = txt

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

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

b = A("b")
c = B("c")
h = C("h")
e = A("e")
n = A("n")
k = A("k")
m = B("m")
a = A("a")
d = C("d")

b.p = h
b.s = h
b.x = c
c.y = m
c.q = d
c.p = d
h.o = d
h.v = d
h.y = m
e.p = h
e.x = m
e.s = d
n.p = d
n.x = m
n.s = h
k.p = d
k.x = c
k.s = h
m.y = c
m.q = d
m.p = d
a.p = h
a.s = h
a.x = m
d.o = h
d.v = h
d.y = m
assert b.s.y.p.txt == "d"