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

class B:
    def __init__(self, txt: str):
        self.r: I = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.t: J = None
        self.q: G = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.y: C = None
        self.z: H = None
        self.p: I = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

class H:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

class I:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

class J:
    def __init__(self, txt: str):
        self.o: F = None
        self.w: B = None
        self.z: F = None
        self.v: B = None
        self.x: H = None
        self.txt = txt

n = A("n")
h = B("h")
m = C("m")
i = D("i")
e = E("e")
c = F("c")
j = G("j")
f = H("f")
l = I("l")
d = J("d")

n.r = c
n.v = i
h.r = l
m.t = d
m.q = j
i.y = m
i.z = f
i.p = l
e.x = c
e.v = h
c.r = m
j.r = i
f.r = n
l.w = h
d.o = c
d.z = c
d.w = h
d.v = h
d.x = f
assert l.w.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.r: F = None
        self.v: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.r: I = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.t: J = None
        self.q: G = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.y: C = None
        self.z: H = None
        self.p: I = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

class H:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

class I:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

class J:
    def __init__(self, txt: str):
        self.o: F = None
        self.w: B = None
        self.z: F = None
        self.v: B = None
        self.x: H = None
        self.txt = txt

n = A("n")
h = B("h")
m = C("m")
i = D("i")
e = E("e")
c = F("c")
j = G("j")
f = H("f")
l = I("l")
d = J("d")

n.r = c
n.v = i
h.r = l
m.t = d
m.q = j
i.y = m
i.z = f
i.p = l
e.x = c
e.v = h
c.r = m
j.r = i
f.r = n
l.w = h
d.o = c
d.z = c
d.w = h
d.v = h
d.x = f
assert l.w.r.w.txt == "h"