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

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

class C:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.s: E = None
        self.t: E = None
        self.x: A = None
        self.v: G = None
        self.u: F = None
        self.r: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.v: G = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.y: I = None
        self.txt = txt

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

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

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

f.p = a
b.x = a
b.p = l
b.r = n
m.u = a
a.s = l
a.t = l
a.x = f
a.v = i
a.u = n
a.r = m
l.s = b
n.v = i
i.y = j
d.y = m
d.u = b
j.z = b
h.p = a
assert n.v.y.z.r.v.y.z.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.s: E = None
        self.t: E = None
        self.x: A = None
        self.v: G = None
        self.u: F = None
        self.r: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.v: G = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.y: I = None
        self.txt = txt

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

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

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

f.p = a
b.x = a
b.p = l
b.r = n
m.u = a
a.s = l
a.t = l
a.x = f
a.v = i
a.u = n
a.r = m
l.s = b
n.v = i
i.y = j
d.y = m
d.u = b
j.z = b
h.p = a
assert n.v.y.z.r.v.y.z.txt == "b"