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

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

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

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

h.x = k
h.p = k
b.y = n
b.r = h
b.v = h
f.t = n
f.s = n
f.o = m
m.y = n
m.r = c
m.v = c
k.t = b
k.s = b
k.o = b
n.y = m
n.r = h
n.v = h
c.x = k
c.p = f
l.x = k
l.p = k
d.x = k
d.p = k
j.x = k
j.p = f
assert j.x.o.r.p.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.p: C = None
        self.txt = txt

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

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

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

h.x = k
h.p = k
b.y = n
b.r = h
b.v = h
f.t = n
f.s = n
f.o = m
m.y = n
m.r = c
m.v = c
k.t = b
k.s = b
k.o = b
n.y = m
n.r = h
n.v = h
c.x = k
c.p = f
l.x = k
l.p = k
d.x = k
d.p = k
j.x = k
j.p = f
assert j.x.o.r.p.txt == "k"