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: F = None
        self.y: H = None
        self.v: H = None
        self.o: G = None
        self.r: D = None
        self.q: A = None
        self.w: G = None
        self.u: I = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.p: G = None
        self.s: F = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.s: C = None
        self.r: G = None
        self.q: G = None
        self.o: I = None
        self.y: I = None
        self.u: C = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.q: A = None
        self.r: A = None
        self.u: A = None
        self.txt = txt

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

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

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

f.p = g
b.x = g
b.r = g
b.p = j
b.y = c
b.v = c
b.o = h
b.w = h
b.q = f
b.u = n
d.p = f
d.o = l
g.p = h
g.s = j
l.z = d
l.w = f
l.r = b
l.q = b
j.s = d
j.u = d
j.r = h
j.q = h
j.o = n
j.y = n
h.q = f
h.r = f
h.u = f
c.r = h
n.z = f
n.v = j
n.r = c
assert g.p.u.p.p.q.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: F = None
        self.y: H = None
        self.v: H = None
        self.o: G = None
        self.r: D = None
        self.q: A = None
        self.w: G = None
        self.u: I = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.p: G = None
        self.s: F = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.s: C = None
        self.r: G = None
        self.q: G = None
        self.o: I = None
        self.y: I = None
        self.u: C = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.q: A = None
        self.r: A = None
        self.u: A = None
        self.txt = txt

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

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

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

f.p = g
b.x = g
b.r = g
b.p = j
b.y = c
b.v = c
b.o = h
b.w = h
b.q = f
b.u = n
d.p = f
d.o = l
g.p = h
g.s = j
l.z = d
l.w = f
l.r = b
l.q = b
j.s = d
j.u = d
j.r = h
j.q = h
j.o = n
j.y = n
h.q = f
h.r = f
h.u = f
c.r = h
n.z = f
n.v = j
n.r = c
assert g.p.u.p.p.q.txt == "f"