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

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

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

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

b.r = l
b.x = d
b.w = c
h.x = c
h.o = d
i.x = d
i.v = b
n.r = l
n.x = d
n.w = h
c.x = k
c.o = d
m.r = k
m.x = d
m.w = h
d.x = i
d.v = m
l.x = k
l.o = i
k.x = h
k.o = i
assert h.o.x.v.r.o.x.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.x: C = None
        self.w: B = None
        self.txt = txt

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

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

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

b.r = l
b.x = d
b.w = c
h.x = c
h.o = d
i.x = d
i.v = b
n.r = l
n.x = d
n.w = h
c.x = k
c.o = d
m.r = k
m.x = d
m.w = h
d.x = i
d.v = m
l.x = k
l.o = i
k.x = h
k.o = i
assert h.o.x.v.r.o.x.txt == "d"