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

class B:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

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

f = A("f")
g = B("g")
j = C("j")
i = A("i")
n = A("n")
e = C("e")
b = A("b")
h = C("h")

f.q = e
f.p = i
f.z = h
g.q = b
j.o = n
j.w = i
j.v = h
i.q = j
i.p = n
i.z = h
n.q = j
n.z = j
n.p = b
e.o = i
e.w = i
e.v = j
b.q = e
b.p = n
b.z = j
h.o = n
h.w = n
h.v = j
assert f.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.p: A = None
        self.z: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

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

f = A("f")
g = B("g")
j = C("j")
i = A("i")
n = A("n")
e = C("e")
b = A("b")
h = C("h")

f.q = e
f.p = i
f.z = h
g.q = b
j.o = n
j.w = i
j.v = h
i.q = j
i.p = n
i.z = h
n.q = j
n.z = j
n.p = b
e.o = i
e.w = i
e.v = j
b.q = e
b.p = n
b.z = j
h.o = n
h.w = n
h.v = j
assert f.p.p.p.p.txt == "n"