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

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

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

e = A("e")
g = B("g")
b = C("b")
h = B("h")
j = C("j")
c = C("c")
k = A("k")
m = A("m")
d = C("d")

e.v = h
e.p = k
g.o = e
g.u = e
g.y = c
b.v = m
b.x = h
h.o = e
h.u = e
h.y = b
j.v = m
j.x = h
c.v = k
c.x = h
k.v = h
k.p = e
m.v = g
m.p = e
d.v = m
d.x = g
assert m.v.y.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.p: A = None
        self.txt = txt

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

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

e = A("e")
g = B("g")
b = C("b")
h = B("h")
j = C("j")
c = C("c")
k = A("k")
m = A("m")
d = C("d")

e.v = h
e.p = k
g.o = e
g.u = e
g.y = c
b.v = m
b.x = h
h.o = e
h.u = e
h.y = b
j.v = m
j.x = h
c.v = k
c.x = h
k.v = h
k.p = e
m.v = g
m.p = e
d.v = m
d.x = g
assert m.v.y.v.txt == "k"